简体   繁体   English

需要在命令行上使用较低版本的msbuild C#项目,而无需Visual Studio

[英]Need to msbuild C# project of lower version on commandline, without Visual Studio

I need to msbuild C# project of lower version on commandline, I donot have Visual Studios. 我需要在命令行上使用msbuild较低版本的C#项目,我没有Visual Studios。

I am facing the error while building the project: 构建项目时遇到错误:

Microsoft (R) Build Engine Version 2.0.50727.42
[Microsoft .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

.\Project.sln : Solution file error MSB4054: The solution file must be opened in t
he Visual Studio IDE and converted to the latest version before it can be built
by MSBuild.

I have the .sln file and previously someone did build the project from here possibly with the Version 1.0 engine. 我有.sln文件,以前有人确实使用1.0版引擎从此处构建了项目。

Can someone help me with this? 有人可以帮我弄这个吗?

You'll find MSBuild in C:\\Windows\\Microsoft.NET\\Framework[framework version]. 您将在C:\\ Windows \\ Microsoft.NET \\ Framework [framework version]中找到MSBuild。

For instance, the one that came with .NET 2.0 is in C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727. 例如,.NET 2.0附带的文件位于C:\\ Windows \\ Microsoft.NET \\ Framework \\ v2.0.50727中。 I believe that's the one that came with VS 8.0. 我相信这是VS 8.0附带的。

If you need the x64 version, it's in C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727 如果需要x64版本,则位于C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v2.0.50727

In many cases you can just pass the project file to MsBuild and it will compile just fine. 在许多情况下,您只需将项目文件传递给MsBuild,它就可以正常编译。 Forexample: 例如:

msbuild MyProj.csproj /p:Configuration=Release

.csproj files are valid MsBuild XML files whereas .sln files have to be converted into MsBuild scripts on the fly, which is why they are tied to a specific version of Visual Studio. .csproj文件是有效的MsBuild XML文件,而.sln文件必须即时转换为MsBuild脚本,这就是它们与特定版本的Visual Studio绑定的原因。

If you have multiple projects in your solution I would recommend passing the primary/startup project to MsBuild so that all of the dependencies also get built. 如果您的解决方案中有多个项目,建议您将主项目/启动项目传递给MsBuild,以便也可以构建所有依赖项。 This method does not always work and you may run into problems is if you have any solution level dependencies or custom solution configurations specified in the solution file. 如果您在解决方案文件中指定了任何解决方案级别的依存关系或自定义解决方案配置,则此方法并不总是有效,并且可能会遇到问题。

Ok, got permission from client to install VStudios. 好的,已获得客户端安装VStudio的许可。 Installed and built the program :/ 安装并构建程序:/

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

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