VSTS Build失败/发布无法在bin文件夹中找到roslyn\csc.exe [英] VSTS Build fails/Publish fails to find roslyn\csc.exe in the bin folder

查看:235
本文介绍了VSTS Build失败/发布无法在bin文件夹中找到roslyn\csc.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个网站项目,其中安装了以下nuget软件包

We have a website project which has the following nuget packages installed

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=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>

在本地可以正常工作。当安装 DotNetCompilerPlatform 时, install.ps1 脚本将在垃圾箱中创建Roslyn文件夹,并将csc.exe等复制到该文件夹​​中。

Builds work fine locally. When the DotNetCompilerPlatform is installed the install.ps1 the script creates the Roslyn folder in the bin and copies csc.exe etc to the folder.

该代码由第三方编写,并致力于我们的VSTS存储库。我想使用VSTS通过我们的测试/阶段和产品环境来构建和部署网站。

The code is being written by a third party and committed to our VSTS repo. I want to use VSTS to build and deploy the website through our test/stage and prod environments.

VSTS构建管道获取源代码,然后还原软件包并在解决方案上运行Visual Studio Build任务。这是一个网站项目,因此该网站没有项目。构建失败,并出现以下错误

The VSTS build pipeline grabs the source, then restores the packages and runs a Visual Studio Build task on the solution. It is a website project so that is no proj for the site. The build fails with the following error


ASPNETCOMPILER(0,0):错误ASPRUNTIME:找不到
的一部分路径'xxxxxxxxxx\bin\roslyn\csc.exe'。

ASPNETCOMPILER(0,0): Error ASPRUNTIME: Could not find a part of the path 'xxxxxxxxxx\bin\roslyn\csc.exe'.

由于构建只是在恢复软件包R oslyn二进制文件不会复制到bin

As the build is just doing a restore of the package the Roslyn binaries are not copied to the bin.

我还尝试从项目中删除软件包,并从<$中删除编译器。 c $ c> web.config ,但随后出现错误。

I also try removing the packages from the project and deleting the compilers from the web.config but then get the error.


错误CS1056:意外字符'$'

Error CS1056: Unexpected character '$'

我在其中使用一些较新的语言功能。

where I am using some of the newer language features.

I我真的想使PreCompile和Publish自动化,因为目前有太多手动步骤容易出错或滥用。

I really want to automate the PreCompile and Publish as at the moment there are too many manual steps which are open to error or abuse.

一个想法是我不得不添加一个步骤软件包还原后在构建管道中运行以从 DotNetCompilerPlatform 运行 install.ps1 package文件夹,希望将编译器工具复制到bin中。即模仿安装软件包时的操作。但是在走这条路之前,我想看看是否有更好的解决方案。

One thought I had was to add a step in the build pipeline after the package restore to run the install.ps1 from the DotNetCompilerPlatform package folder which will hopefully copy the compiler tools to the bin. i.e. mimic what is done when you install the package. But before I went down this road I wanted to see if there was a better solution.

推荐答案

一个建议是更新您的'。csproj'更改您的构建定义(在代码本身中为 ),如下所示:将roslyn 直接复制到 bin 文件夹,而不是默认输出目录

One suggestion is updating your '.csproj' to change your build definition(in the code itself) like below to copy the roslyn directly into bin folder rather than the 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构建定义

This way you can't change the VSTS Build definition

这篇关于VSTS Build失败/发布无法在bin文件夹中找到roslyn\csc.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆