Reputation: 11731
I have a project which is currently in .Net version 4.5.1 and it has normal .Net project structure.
I am trying to build this project using Jenkins on a Windows agent where only VS 2017 is installed.
I am building this project using MSBuild 15 which ships with VS 2017, which is at the location - C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
But I am facing error -
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
As per my understanding, as my project does not have sdk based structure - it is not building the solution and due to that, I will force the admin to install VS 2015 on the windows agent OR I need to restructure all my project to sdk based structure as per this post -
https://www.natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/
OR is there any better way to handle this situation?
Upvotes: 0
Views: 1295
Reputation: 76760
Building normal .Net project with MSBuild 15 which ships with Visual Studio 2017
To resolve this issue, you should make sure you have the .NET Framework 4.5.1 Targeting Pack installed on the Windows agent where Jenkins installed at first.
You can launch the Visual Studio Installer, modify it, check if the .NET Framework 4.5.1 targeting pack
is selected on the Individual components:
If it was already installed on the Windows agent, then you should to verify if .net framework reference path on the jenkins machine matches on your local machine.
If not, you can use the parameter FrameworkPathOverride
with MSBuild command line to overwrite the .net framework path when you build solution with jenkins, like:
MSBuild.exe” YourSolution.sln /p:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1"
Hope this helps.
Upvotes: 2
Reputation: 2176
As your message states, you have to install the .net framework 4.5.1 in your build server (where vs2017) is installed. It is required because your project uses and targets some dlls needed to build your project.
First you could try to only install the targeting framework from https://www.microsoft.com/en-us/download/details.aspx?id=40772
If it does not work add to the installation the full version of the 4.5.1 framework.
Upvotes: 0