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:

Please use following command in pipeline.yaml hope it should work.

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: '17.0'
  configuration: 'Release'
  clean: true
  msbuildArchitecture: 'x64

Actually you used vsVersion of vs 2019(16.0) but since you are compiling .Net 6.0 which is fully supported in vs 2022(17.0)