使用C#6构建TeamCity [英] TeamCity Build using C#6

查看:88
本文介绍了使用C#6构建TeamCity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用TeamCity(9.0.1)作为构建服务器,但是最近升级了ASP.NET MVC解决方案以使用VS2015和C#6语法,现在我在构建服务器上收到以下错误消息:

We use TeamCity (9.0.1) as our build server, but having recently upgraded our ASP.NET MVC solution to use VS2015 and C#6 syntax, I now get the following error message on our build server:

无法启动构建运行器

Can not start build runner

,更具体地说:

C:\ TeamCity \ buildAgent \ work \ 86ee61c6c333dc3d \ MyApplication \ MyApplication.csproj.metaproj:错误MSB4025:无法加载项目文件.找不到文件'C:\ TeamCity \ buildAgent \ work \ 86ee61c6c333dc3d \ MyApplication \ MyApplication.csproj.metaproj'.

C:\TeamCity\buildAgent\work\86ee61c6c333dc3d\MyApplication\MyApplication.csproj.metaproj : error MSB4025: The project file could not be loaded. Could not find file 'C:\TeamCity\buildAgent\work\86ee61c6c333dc3d\MyApplication\MyApplication.csproj.metaproj'.

我在几个不同的帖子中都遵循了建议(尽管这些帖子主要是针对TFS而不是TeamCity,并且不直接引用丢失的".metaproj"文件):

I followed the advice in several different posts (though these are mainly TFS focused rather than TeamCity and don't refer to the missing ".metaproj" file directly):

  • TFS 2013 building .NET 4.6 / C# 6.0
  • C# 6.0 TFS Builds
  • Running TFS Build with C# 6.0 features

因此,总而言之,我对构建服务器进行了以下更改:

So, in summary, I have made the following changes to my Build Server:

  1. 已安装Visual Studio 2015 Update 2
  2. 更改了执行构建的PowerShell脚本

来自:

msbuild'.. \ MyApplication.sln'/t:构建/p:Configuration =发布/p:RunCodeAnalysis =始终/p:VisualStudioVersion=12.0

msbuild '..\MyApplication.sln' /t:Build /p:Configuration=Release /p:RunCodeAnalysis=Always /p:VisualStudioVersion=12.0

收件人:

msbuild'.. \ MyApplication.sln'/t:构建/tv:14.0/p:GenerateBuildInfoConfigFile = false /p:Configuration =发布/p:RunCodeAnalysis =始终/p:VisualStudioVersion = 14 .0

msbuild '..\MyApplication.sln' /t:Build /tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:Configuration=Release /p:RunCodeAnalysis=Always /p:VisualStudioVersion=14.0

注意:

  • 如果我登录到Build Server并尝试编译解决方案 使用VisualStudio 2015则可以正常工作.

  • If I log onto the Build Server and attempt to compile the solution using VisualStudio 2015 then this works fine.

在上述职位之一中,它讨论了从 从"TfvsTemplate.11.1.xaml"到"TfvsTemplate.12.xaml".但据我 不能告诉,我不使用或引用.也许我很误会 在这种情况下,白痴的下一步操作指南将是 非常感谢.

In one of the posts mentioned above, it discussed upgrading from "TfvsTemplate.11.1.xaml" to "TfvsTemplate.12.xaml". But as far as I can't tell, I don't use or reference this. Maybe I'm much mistaken here, in which case an idiot's guide of what to do next would be gratefully received.

推荐答案

最后....我们修复了它.

Finally....we fixed it.

我必须在Build Server上执行以下步骤:

I had to take the following steps on the Build Server:

  1. 已安装VS2015 Update 2
  2. 编辑环境变量"PATH"以从C:\ Program Files(x86)\ MSBuild \ 12.0 \ Bin \更改一项设置.到C:\ Program Files(x86)\ MSBuild \ 14.0 \ Bin \;
  3. 由于我们使用TeamCity来启动PowerShell脚本,因此又会关闭MSBuild.我将PowerShell模块PSAKE从4.2更新到4.6(但这可能不是必需的)
  4. 创建一个新的环境变量"MSBuildEmitSolution",并将其值设置为"1"
  5. 将文件"Microsoft.Build.Tasks.v12.0.dll"从"C:\ Program Files(x86)\ MSBuild \ 12.0 \ Bin \ amd64"复制到"C:\ Program Files(x86)\ MSBuild \ 14.0 \ Bin \ amd64".不知道为什么在我们的BUILD日志中将其报告为错误,因为它不是AMD机器...
  6. 使用NUGET,必须将包"Microsoft.Net.Compilers"添加到每个使用C#6语法的C#项目中(基本上都是这些)

并非所有上述步骤都是绝对必要的,但我建议确实必须执行步骤1.和5..

Not all of the above steps may be strictly necessary, but I would suggest that certainly steps 1. and 5. were definitely required.

HTH

格里夫

这篇关于使用C#6构建TeamCity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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