'Error view Index.cshtml not found for ASP.NET Core 6 MVC app when build on Azure build agent
I get an error "View Index.cshtml not found" for my ASP.NET Core 6 MVC app when building it on Azure build agent, but when building locally, it is working fine.
I tried same command which is executed on build agent still could not get the issue. Tried several code changes to fix this issue but still no clues. Searched on net even on stackoverflow but sadly no solution works.
Please someone help me out.
I am using following input in pipeline.yaml:
solution: 'src/Indl.Web.Core.sln'
msbuildArgs: '/property:OutDir="$(BUILD.BINARIESDIRECTORY)"\x64\ /p:RunWixToolsOutOfProc=true /p:PackageVersion=$(GitVersion.SemVer) /p:SASigning=true /p:SACertificate=prod.prot /p:PackageOutputPath="$(BUILD.BINARIESDIRECTORY)"\x64\'
platform: 'x64'
vsVersion: '16.0'
configuration: 'Release'
clean: true
msbuildArchitecture: 'x64
The solution has one more mvc app which is working as expected. I cross verified dll and found that the section 'AspNetCoreGeneratedDocument' is not available in dll which is usually has all view related information.
Solution 1:[1]
I've experienced the same Issue few days ago. I suspect that the problem is related to the update to .net 6.0.2.
It seems like, that with the update the Packages '"Microsoft.CodeAnalysis.Compilers' and 'Microsoft.Net.Compilers.Toolset' are missing.
After adding the following lines to all Projects containg .cshtml/.html files everything worked as excpected and the files are available under AspNetCoreGeneratedDocument in the DLLs.
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.1.0" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Schamal |
