我有一个较旧的代码库,它使用ASP.NET网站(,而不是,一个ASP.NET Web应用程序),并试图在Azure DevOps上为它构建管道。
当进程到达aspnet_compiler.exe
时遇到一些困难之后,我创建了一个简单的测试解决方案,其中包含一个ASP.NET表单站点,它是从VS2019中的模板生成的。然后,我使用ASP.NET模板创建了一个管道,并运行它,最终以熟悉的失败告终。测试解决方案和实际解决方案在同一地点失败了,所以至少我已经指出了这个问题.不幸的是,我不知道怎么解决这个问题。
构建步骤的完整日志位于我的帖子底部,但这里是我被特别困住的地方:
Project "D:\a\9\s\Hello.sln" (1) is building "D:\a\9\s\WebSite1_1_.metaproj" (2) on node 1 (default targets).
Build:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_51752 -p WebSite1\ -u -f PrecompiledWeb\localhost_51752\
##[error]WebSite1\web.config(116,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
我应该注意,这似乎与Microsoft.CodeDom.Providers.DotNetCompilerPlatform
程序集并没有具体的关系。在我的实际ASP.NET网站(不是我正在使用的这个小测试)中,如果站点的web.config
包含以下内容,就会发生同样的"Error ASPCONFIG: ... * could not be located.
“错误:
<compilation debug="true" defaultLanguage="c#" targetFramework="4.8">
<assemblies>
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
在这种情况下,它将抛出相同的错误,而是关于Microsoft.Web.Infrastructure
。显然,aspnet_compiler.exe
找不到我的引用,但是我不知道缺少什么--是引用没有被复制到某个地方,还是过程没有在正确的地方查找它们,或者.?
下面是整个Azure DevOps管道构建日志:
##[section]Starting: Build solution
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.166.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\9\s\Hello.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=f1e19740-d1c0-4435-a66d-d2b7ccec211f|SolutionDir=D:\a\9\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\9\a\\" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_ab00089e-3c64-4607-ad03-57473b1db76f_build_3_0"
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/28/2020 6:48:44 PM.
Project "D:\a\9\s\Hello.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "release|any cpu".
Project "D:\a\9\s\Hello.sln" (1) is building "D:\a\9\s\WebSite1_1_.metaproj" (2) on node 1 (default targets).
Build:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_51752 -p WebSite1\ -u -f PrecompiledWeb\localhost_51752\
##[error]WebSite1\web.config(116,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
Done Building Project "D:\a\9\s\WebSite1_1_.metaproj" (default targets) -- FAILED.
Done Building Project "D:\a\9\s\Hello.sln" (default targets) -- FAILED.
Build FAILED.
"D:\a\9\s\Hello.sln" (default target) (1) ->
"D:\a\9\s\WebSite1_1_.metaproj" (default target) (2) ->
(Build target) ->
D:\a\9\s\WebSite1\web.config(116): error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. [D:\a\9\s\WebSite1_1_.metaproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:09.47
##[error]Process 'msbuild.exe' exited with code '1'.
##[section]Finishing: Build solution
发布于 2020-08-31 18:26:15
网站在Azure DevOps管道中工作似乎需要一点额外的爱,但它们可以工作。这是我降落的地方..。
例如,在一个新的网站项目中,Bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh
的内容默认为:
..\..\..\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
...but应该是:
..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
*.csproj
可以告诉它。添加自定义NuGet还原任务(其中"WebSite1
“是网站所在的目录):steps:
- task: NuGetCommand@2
displayName: 'NuGet Restore for Web Site'
inputs:
command: custom
arguments: 'restore $(Build.SourcesDirectory)\WebSite1\packages.config -SolutionDirectory $(Build.SourcesDirectory)'
aspnet_compiler.exe
之前将所有的PowerShell文件放在Bin目录中。您必须自己执行复制文件任务:steps:
- task: CopyFiles@2
displayName: 'Copy Roslyn files'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\RoslynLatest'
TargetFolder: '$(Build.SourcesDirectory)\WebSite1\Bin\roslyn'
https://stackoverflow.com/questions/63639769
复制相似问题