windows - Use MSBuild to build ASP.Net project targeting .Net 4.0 on Server 2016 -


i have jenkins build server set on windows server 2016. have 'build tools visual studio 2017' (latest version of msbuild) installed. when try build project targeting .net 4.0 error message:

c:\program files (x86)\microsoft visual studio\2017\buildtools\msbuild\15.0\bin\microsoft.common.currentversion.targets(1122,5): error msb3644: reference assemblies framework ".netframework,version=v4.0" not found. resolve this, install sdk or targeting pack framework version or retarget application version of framework have sdk or targeting pack installed. note assemblies resolved global assembly cache (gac) , used in place of reference assemblies. therefore assembly may not correctly targeted framework intend.

so check 'c:\program files (x86)\reference assemblies\microsoft\framework.netframework\v4.0' , find that, sure enough, there no dlls in folder, xml files.

so try install full .net 4.0 framework thinking install reference assemblies these messages:

1) microsoft .net framework 4 part of operating system. not need install .net framework 4 redistributable.

2) same or higher version of .net framework 4 has been installed on computer.

so google around , find several sites things '.net framework 4.5.2 considered "in-place update" .net 4 family, no need recompile applications' , think maybe can install .net 4.5.2 targeting packs , target them using parameter msbuild:

/property:frameworkpathoverride="c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.5.2" 

sure enough, seems work. problem don't understand reference assemblies , targeting packs , whatnot. i'm concerned that, while seems may have solved problem, discover later on, farther down road, have introduced other nasty issue.

questions

  • are there problems have done?
  • is there better way go doing this?

update

i failed mention tried install .net framework 4.0.3 milti-targeting pack via this link following error:

microsoft .net framework 4 multi-targeting pack not found. please repair installation microsoft visual studio 2010 in order update.

short answer

i not recommend continue using frameworkpathoverride. changing application compile if .net 4.5.2, not 4.0. there unintended consequences.

you can download .net framework 4.0 targeting pack here: https://www.microsoft.com/en-us/download/details.aspx?id=29052

or, can download .net 4.0 targeting pack visual studio 2017 installer selecting in "individual components".

vs installer

more details

the problem don't understand reference assemblies , targeting packs , whatnot.

"reference assemblies" header files in .net. when compile application .net framework 4.0, "targeting" apis available in .net 4.0 runtime. forms minimum runtime version application can run on. however, application execute on version of .net framework runtime installed on machine (it's global, shared version), newer 4.0.

installing targeting pack means installing copy of 'header files' machine. machine still have .net framework 4.5.x or 4.6 runtime installed.

as .net 4.0 out of support , machines have 4.5.2 or newer, should consider compiling against .net framework 4.5.2 instead. can project properties page in visual studio. or, can edit csproj file.

if you're using "classic", more verbose csproj format, this

   <propertygroup>       <targetframeworkversion>v4.5.2</targetframeworkversion>    </propertygroup> 

if you're using "new", slimmer csproj vs 2017, be

   <propertygroup>       <targetframework>net452</targetframework>    </propertygroup> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -