Author Topic: How can I set the target .Net Framework version for csc.exe?  (Read 3833 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
How can I set the target .Net Framework version for csc.exe?
« on: March 16, 2015, 04:25:23 AM »
Each of .Net Framework version has own versions of csc.exe, msbuild.exe, etc. On my notebook all .Net Framework versions (newer than .Net 1.0) are installed. I see such directories:



I created some new Windows-variables:

Code: [Select]
%NET30% = "C:\Windows\Microsoft.NET\Framework64\v3.0"
%NET35% = "C:\Windows\Microsoft.NET\Framework64\v3.5"
%NET40% = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"

and use them when I use csc.exe, al.exe and msbuild.exe manually or through the BAT-files (from the usual cmd.exe). It allows to me compile my code sources on my notebook (it is not a "super car"), which hasn't Visual Studio, but has all necessary .Net Framework versions installed.

For example, I use that variables in my BAT-files. Sample:

Code: [Select]
:: (c) Andrey Bushman, 2015
:: Building the .Net-extension for AutoCAD 2009(x86|x64), 2013(AnyCPU),
:: 2015(AnyCPU) with locating of some functional in the separate netmodule-file.

:: AutoCAD 2009x64
:: 1. module
start /WAIT "AutoCAD 2009x64" %net35%\csc @.\acad2009x64-netmodule.rsp .\Commands.cs .\ExtensionApplication.cs .\ExtensionMethods.cs

:: 2. assembly
start /WAIT "AutoCAD 2009x64" %net35%\csc @.\acad2009x64-entry-point.rsp /addmodule:".\\proxy.R17.2x64.netmodule" .\EntryPoint.cs

:: AutoCAD 2009x86
:: 1. module
start /WAIT "AutoCAD 2009x86" %net35%\csc @.\acad2009x86-netmodule.rsp .\Commands.cs .\ExtensionApplication.cs .\ExtensionMethods.cs

:: 2. assembly
start /WAIT "AutoCAD 2009x86" %net35%\csc @.\acad2009x86-entry-point.rsp /addmodule:".\\proxy.R17.2x86.netmodule" .\EntryPoint.cs

:: AutoCAD 2013
:: 1. module
start /WAIT "AutoCAD 2013" %net40%\csc @.\acad2013-netmodule.rsp .\Commands.cs .\ExtensionApplication.cs .\ExtensionMethods.cs

:: 2. assembly
start /WAIT "AutoCAD 2013" %net40%\csc @.\acad2013-entry-point.rsp /addmodule:".\\proxy.R19.0.netmodule" .\EntryPoint.cs

:: AutoCAD 2015
:: 1. module
start /WAIT "AutoCAD 2015" %net40%\csc @.\acad2015-netmodule.rsp .\Commands.cs .\ExtensionApplication.cs .\ExtensionMethods.cs

:: 2. assembly
start /WAIT "AutoCAD 2015" %net40%\csc @.\acad2015-entry-point.rsp /addmodule:".\\proxy.R20.0.netmodule" .\EntryPoint.cs

The same .Net Framework versions are installed on my machine in office. Also this computer has MS Visual Studio.2013 installed. In the IDE I see such list of enabled .Net Framework versions:



The .Net Framework 4.5, .Net Framework 4.5.1 items exist also...

My question: How can I set the target .Net Framework version (.Net 4.0, or .Net 4.5, or .Net 4.5.1) when I use the tools (csc.exe) from the %NET40% directory on my notebook manually, or in my BAT-files? I don't see this option in the csc.exe /? output.
« Last Edit: March 16, 2015, 04:47:17 AM by Andrey Bushman »

owenwengerd

  • Bull Frog
  • Posts: 451
Re: How can I set the target .Net Framework version for csc.exe?
« Reply #1 on: March 16, 2015, 06:56:50 AM »
You should always call MSBuild.exe, the latest version, and let it handle those details based on the TargetFrameworkVersion set in your project files.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How can I set the target .Net Framework version for csc.exe?
« Reply #2 on: March 16, 2015, 07:02:55 AM »
Thank you, Owen.