简体   繁体   中英

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.

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.

Can someone help me with this?

You'll find MSBuild in C:\\Windows\\Microsoft.NET\\Framework[framework version].

For instance, the one that came with .NET 2.0 is in C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727. I believe that's the one that came with VS 8.0.

If you need the x64 version, it's in 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. 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.

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. 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. Installed and built the program :/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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