[英]VSTS Build fails/Publish fails to find roslyn\csc.exe in the bin folder
我们有一个网站项目,其中安装了以下nuget软件包
Microsoft.CodeDom.Providers.DotNetCompilerPlatform - 1.0.8
Microsoft.Net.Compilers - 2.4.0
web.config
具有以下内容
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
本地工作正常。 安装DotNetCompilerPlatform
, install.ps1脚本将在垃圾箱中创建Roslyn文件夹,并将csc.exe等复制到该文件夹中。
该代码是由第三方编写的,并已提交给我们的VSTS存储库。 我想使用VSTS通过我们的测试/阶段和产品环境来构建和部署网站。
VSTS构建管道获取源代码,然后还原软件包并在解决方案上运行Visual Studio Build任务。 这是一个网站项目,因此该网站没有项目。 构建失败,并出现以下错误
ASPNETCOMPILER(0,0):错误ASPRUNTIME:找不到路径“ xxxxxxxxxx \\ bin \\ roslyn \\ csc.exe”的一部分。
由于构建只是在还原软件包,因此R oslyn二进制文件不会复制到bin中 。
我也尝试从项目中删除程序包,并从web.config
删除编译器,但会收到错误消息。
错误CS1056:意外字符'$'
我在其中使用一些较新的语言功能。
我真的想使PreCompile和Publish自动化,因为目前有太多手动步骤,容易出错或滥用。
我曾经以为是要在软件包还原后在构建管道中添加一个步骤,以从DotNetCompilerPlatform
软件包文件夹中运行install.ps1 ,这有望将编译器工具复制到bin中。 即模拟安装软件包时的操作。 但是在走这条路之前,我想看看是否有更好的解决方案。
一个建议是更新您的'.csproj',以更改构建定义( 在代码本身中 ),如下所示, copy the roslyn
直接copy the roslyn
到bin
文件夹而不是default output directory
。
<Target Name="CopyRoslynFiles" AfterTargets="AfterBuild" Condition="!$(Disable_CopyWebApplication) And '$(OutDir)' != '$(OutputPath)'">
<ItemGroup>
<RoslynFiles Include="$(CscToolPath)\*" />
</ItemGroup>
<MakeDir Directories="$(WebProjectOutputDir)\bin\roslyn" />
<Copy SourceFiles="@(RoslynFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" SkipUnchangedFiles="true" Retries="$(CopyRetryCount)" RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)" />
</Target>
这样,您就无法更改VSTS构建定义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.