Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Target specific version of .NET with MSBuild

Tags:

I have a solution that is being referenced by a MSBuild project. In the solution, I am referencing several projects that are targeting .NET 4.0. How can I tell MSBuild to ignore the project's configuration and just target .NET 3.5?

like image 964
Daniel A. White Avatar asked Mar 10 '10 18:03

Daniel A. White


People also ask

Is MSBuild included in .NET framework?

It is installed as part of . NET (Full Framework, not just Client Profile), you don't need SDK.

How do I select a .NET version?

Open your project's source folder and, in the address bar, type "cmd" and press Enter. It will open the command prompt with the project path. Execute the following command: dotnet --version . It will display your project's current SDK version,i.e., 2.1.


1 Answers

A command similar to the following should work

msbuild YourSolution.sln /tv:3.5 /p:TargetFrameworkVersion=v3.5

or

msbuild YourSolution.sln /p:TargetFrameworkVersion=v3.5

/tv (or /toolsversion) Indicates which version of the MSBuild tools you want to use, and the property TargetFrameworkVersion indicates the target framework. In your case just specifying that property should be fine, but if you want to use the 3.5 MSBuild toolset you can sepcify it with /tv as I did in the first command.

like image 123
Sayed Ibrahim Hashimi Avatar answered Oct 22 '22 06:10

Sayed Ibrahim Hashimi