Skip to content

Commit 32f4bca

Browse files
authored
mvcbuildviews workaround
1 parent fcb1d97 commit 32f4bca

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

troubleshooting/codeql-builds/compiled-languages-csharp.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ For `Error ASPCONFIG: It is an error to use a section registered as allowDefinit
165165

166166
For `Error ASPCONFIG: Could not load type 'X.Y.Z'`, ensure that you do not have excluded `.cshtml`, `.ashx`, `.ashx.cs`, `.aspx` or `.aspx.cs` files on disk in existing `Views` folders or the Root folder of your project! You can show hidden files in your solution view to hunt these down and remove from these folders. MvcBuildViews does not observe the file include from the csproj when compiling the application. You may have to hunt these down one by one, so adding `<MvcBuildViews>true</MvcBuildViews>` to your local .csproj may help you get this done on your local machine with Visual Studio. The `Error List` view in Visual Studio will have a column that shows you the actual File name you need to delete.
167167

168+
To avoid building and scanning any view code in your project (potential false negatives in the scan as view engine code may not be evaluated for vulnerabilities) and to workaround the requirement that MvcBuildViews is automatically injected. Consider this [community contributed suggestion](https://github.com/github/codeql/issues/11890#issuecomment-1496970164):
169+
170+
```powershell
171+
tweaking the csproj file with powershell during the GitHub Action so that the hard-coded condition "gets fooled", basically. Something like this:
172+
173+
$filePath = (Join-Path $pwd '\SUBFOLDER\YOURCSPROJFILE.csproj')
174+
$csproj = [xml](Get-Content $filePath)
175+
$buildTargetNode = $csproj.Project.Target | ? name -eq "MvcBuildViews"
176+
$buildTargetNode.SetAttribute("Condition", "'`$(MvcBuildViews)'=='false'")
177+
$csproj.Save($filePath)
178+
```
179+
180+
168181
## MSB4216 - error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x64"
169182

170183
```

0 commit comments

Comments
 (0)