简体   繁体   English

强制使用msbuild 4.0在.Net 4.0中编译项目,即使.Net fw也是如此。 4.5已安装

[英]Force to use msbuild 4.0 to compile the project in .Net 4.0 even when .Net fw. 4.5 is installed

I have an old legacy application that was built in .Net fw. 我有一个内置于.Net fw中的旧版旧应用程序。 3.5. 3.5。 However i managed to get it upgraded till .Net fw. 但是,我设法将其升级到.Net fw。 4.0 and cannot further migrate it to higher version as there are old components and third party dlls. 4.0,并且由于存在旧组件和第三方dll,因此无法进一步将其迁移到更高版本。

Now for a new integration work i am using a dll that is built in .Net fw 4.5 and its a very small dll which just makes some internal call i believe. 现在,对于新的集成工作,我使用的是.net fw 4.5中内置的dll,并且它是一个非常小的dll,我相信它会进行一些内部调用。

When i compile in VS 2010 specifing tools version as 4.0 and target framework as 4.0 it still gives me error saying assembly reference missing? 当我在VS 2010指定工具版本为4.0,目标框架为4.0的情况下进行编译时,仍然出现错误,提示缺少程序集引用? and also gives details that the dll is of .Net fw 4.5 and the project is targeted to 4.0. 并且还提供了该dll是.Net fw 4.5的详细信息,并且该项目的目标是4.0。

However when i uninstalled .Net fw 4.5 and vs 2015, 2013 and re installed 2010 and compiled it worked. 但是,当我卸载.Net fw 4.5和vs 2015、2013并重新安装2010并对其进行了编译时。 and checked by deploying also. 并通过部署进行检查。

Now since my build server has .Net 4.5.2 installed, i do not want to do all these uninstallation job. 现在,由于我的构建服务器已安装.Net 4.5.2,因此我不想执行所有这些卸载工作。

Is there any way / workaround for making the project build in msbuild 4.0 and compile only by .Net fw 4.0 even when .Net 4.5 is installed in the machine? 有没有什么方法/解决方法可以使项目在msbuild 4.0中构建,并且即使在计算机中安装了.Net 4.5时也只能通过.Net fw 4.0进行编译?

Thanks a lot for the suggestions and helping me out 非常感谢您的建议并帮助我

Unfortunately the answer is No. 不幸的是答案是否定的。

Dot Net 4.5 was an in place upgrade to Dot Net 4.0. 点网4.5是就地升级到点网4.0。

See this Scott Hanselman Blog Post 参见此Scott Hanselman博客文章

You could try using MSBuild from the command line. 您可以尝试从命令行使用MSBuild。 Sometimes Visual Studio is overly aggressive in how 'helpful' it is with resolving assembly reference. 有时,Visual Studio在解决程序集引用方面有多大的帮助性。

The version of MSBuild that shipped with Dot Net 4.0 is at this path: Dot Net 4.0附带的MSBuild版本位于以下路径:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

That .Exe file is not the same after the 4.5 upgrade, but it is worth a try. 4.5升级后,该.exe文件并不相同,但是值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM