CI 服务器上的 .NET 4.0 构建问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2730765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:13:10  来源:igfitidea点击:

.NET 4.0 build issues on CI server

.net.net-4.0msbuildbuildcontinuous-integration

提问by DMcKenna

Anybody manage to get .NET 4.0 applications compiling on a CI server without installing Visual Studio 2010 on a CI server?

有人设法在 CI 服务器上编译 .NET 4.0 应用程序,而无需在 CI 服务器上安装 Visual Studio 2010?

No SDK exists for .NET 4.0. Have installed .NET 4.0 on CI Server. Msbuild.exe works for simple projects and give the following warning:

.NET 4.0 不存在 SDK。已在 CI 服务器上安装了 .NET 4.0。Msbuild.exe 适用于简单项目并给出以下警告:

(GetReferenceAssemblyPaths target) -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

(GetReferenceAssemblyPaths 目标)-> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9):警告 MSB3644:框架“.NETFramework,Version=v4.0”的参考程序集没有找到。要解决此问题,请为此框架版本安装 SDK 或 Targeting Pack,或者将您的应用程序重新定位到安装了 SDK 或 Targeting Pack 的框架版本。请注意,程序集将从全局程序集缓存 (GAC) 中解析,并将用于代替引用程序集。因此,您的程序集可能没有正确针对您想要的框架。

回答by JeremyWeir

You don't need to install VS anymore, you can install the "Microsoft Windows SDK for Windows 7 and .NET Framework 4" now.

您不再需要安装 VS,您现在可以安装“Microsoft Windows SDK for Windows 7 and .NET Framework 4”。

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b

回答by resnyanskiy

SDK for .NET 4.5 available here. Installer works well with proxy with basic authorization. Supported Operating Systems: Windows 8, Windows Server 2012, Windows 7, Windows Server 2008 R2

适用于 .NET 4.5 的 SDK 可在此处获得。安装程序与具有基本授权的代理配合良好。支持的操作系统:Windows 8、Windows Server 2012、Windows 7、Windows Server 2008 R2

P.S. My answer is more like a comment to Jeremy answer, but I have not enough reputation to comment on the answers.

PS 我的回答更像是对Jeremy answer的评论,但我没有足够的声誉来评论这些答案。

回答by kite

other alternative: without installing Net 4.0 SDK or vs 2010

其他选择:不安装 Net 4.0 SDK 或 vs 2010

Copy the reference assemblies folder from your dev machine to build server(190MB).

将参考程序集文件夹从您的开发机器复制到构建服务器(190MB)。

use msbuild -p:FrameworkPathOverride option to point to reference assemblies folder

使用 msbuild -p:FrameworkPathOverride 选项指向引用程序集文件夹

the reference assemblies location:

参考程序集位置:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 or C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 或 C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

found this from:

发现这个:

.NET 4.0 build server reference assemblies warnings MSB3644

.NET 4.0 构建服务器参考程序集警告 MSB3644

If you get this error: "Microsoft.WebApplication.targets was not found" - just copy the target from dev machine https://stackoverflow.com/a/5344246/423356

如果您收到此错误:“未找到 Microsoft.WebApplication.targets” - 只需从开发机器复制目标https://stackoverflow.com/a/5344246/423356

if mvc3 is not installed in build server; "add deployable assemblies" to the mvc project http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

如果构建服务器中未安装 mvc3;“添加可部署程序集”到 mvc 项目 http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

If you have error building the MSTest project without the sdk or visual studio installed; There are several blog post about this, to bad the solution is too complex for me. I use NUnit instead of MSTest

如果在未安装 sdk 或 Visual Studio 的情况下构建 MSTest 项目时出错;有几篇关于这个的博客文章,糟糕的是解决方案对我来说太复杂了。我使用 NUnit 而不是 MSTest

回答by Colonel Panic

This page lists .NET SDKs for each Visual Studio version. http://blogs.msdn.com/b/dotnet/p/dotnet_sdks.aspx

此页面列出了每个 Visual Studio 版本的 .NET SDK。http://blogs.msdn.com/b/dotnet/p/dotnet_sdks.aspx

For a smaller download choose the 'developer pack' or 'targeting pack' rather than the full Windows SDK.

对于较小的下载,请选择“开发人员包”或“目标包”而不是完整的 Windows SDK。