首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Azure DevOps管道可以建立一个ASP.NET网站吗?

Azure DevOps管道可以建立一个ASP.NET网站吗?
EN

Stack Overflow用户
提问于 2020-08-28 19:20:48
回答 1查看 1.7K关注 0票数 2

我有一个较旧的代码库,它使用ASP.NET网站(,而不是,一个ASP.NET Web应用程序),并试图在Azure DevOps上为它构建管道。

当进程到达aspnet_compiler.exe时遇到一些困难之后,我创建了一个简单的测试解决方案,其中包含一个ASP.NET表单站点,它是从VS2019中的模板生成的。然后,我使用ASP.NET模板创建了一个管道,并运行它,最终以熟悉的失败告终。测试解决方案和实际解决方案在同一地点失败了,所以至少我已经指出了这个问题.不幸的是,我不知道怎么解决这个问题。

构建步骤的完整日志位于我的帖子底部,但这里是我被特别困住的地方:

代码语言:javascript
运行
复制
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.“错误:

代码语言:javascript
运行
复制
    <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管道构建日志:

代码语言:javascript
运行
复制
##[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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-31 18:26:15

网站在Azure DevOps管道中工作似乎需要一点额外的爱,但它们可以工作。这是我降落的地方..。

  1. 管道环境没有安装Visual。确保您的*.refresh文件指向下载的包(即NuGet自动放入包目录),而不是指向Visual共享包目录。

例如,在一个新的网站项目中,Bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh的内容默认为:

代码语言:javascript
运行
复制
..\..\..\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll

...but应该是:

代码语言:javascript
运行
复制
..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll

  1. NuGet不知道它需要还原网站的包,因为没有*.csproj可以告诉它。添加自定义NuGet还原任务(其中"WebSite1“是网站所在的目录):

代码语言:javascript
运行
复制
steps:
- task: NuGetCommand@2
  displayName: 'NuGet Restore for Web Site'
  inputs:
    command: custom
    arguments: 'restore $(Build.SourcesDirectory)\WebSite1\packages.config -SolutionDirectory $(Build.SourcesDirectory)'

  1. NuGet不会运行安装PowerShell脚本,在运行aspnet_compiler.exe之前将所有的PowerShell文件放在Bin目录中。您必须自己执行复制文件任务:

代码语言:javascript
运行
复制
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'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63639769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档