DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stateless vs. Stateful Widgets: Make the Right Choice for Your Flutter App
  • How to Build Your Own AI SRE From Scratch
  • AWS 7R Migration Strategies: A Decision Framework for Engineering Teams
  • Stop Preparing for Audits — Build the Pipeline That Audits Itself

Trending

  • Should Developers Switch From SQLite to DuckDB?
  • Searching Kafka Without an Index: Lessons From Building Message Search for Kafdrop
  • Delta Lake UniForm to Snowflake: Cross-Platform Table Access Without a Second Copy
  • Giving AI Agents Safe Access to Legacy Systems: Introducing legacy2mcp

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. How I Resolved the Error ''The Reference Assemblies for Framework 'v4.5.1' Were Not Found''

How I Resolved the Error ''The Reference Assemblies for Framework 'v4.5.1' Were Not Found''

If you've come across this issue while programming your .NET projects in Windows, then this post might have your answer.

By 
Neel Bhatt
·
May. 08, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
20.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Nowadays, I am experimenting a lot to implement CI\CD for all our .Net projects along with BitBucket(Git), Jenkins, Sonar, Fortify, Visual Studio 2017 tools, Artifactory, Dev cloud, VMs, Docker, and many more.

I will post a series of detailed posts for this in the future, but I just wanted to share the resolution for an error which I faced today.

So, basically:
  • We have a bunch of .Net projects under one solution.
  • These projects are mainly .Net version 4.5.1.
  • The first step is to build these projects on Jenkins using a Windows agent.

The Challenge

Here comes the challenging part - the Windows agent on which we are going to build our projects, has Visual Studio 2017 along with all required tooling. So the projects which are under VS 2015, but we want them to build with VS 2017 build tools

The challenge is to build our normal .Net projects with Visual Studio 2017 MSBuild, which generally resides in the location C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe.

Now, when I try to build a big solution (which has around 30 projects) with VS 2017 MSBuild, it throws this error:

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.

I was wondering why this happened, because I thought 4.5.1 was also present on the Windows agent.

The Solution

After much struggling and different tries (more than 200 builds on the agent), I finally found a solution which helped me  get rid of the above error. The solution which worked for me was to add FrameworkPathOverride as a parameter along with your MSBuild commands.

So basically the command would look like:

bat '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\MSBuild.exe" MySolutionName.sln /p:Configuration=Debug /p:Platform=\"Any CPU\" - p:FrameworkPathOverride="C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5″'

Important Notes:
  • Make sure you have the required sdk installed on your agent; if not, install it first, no need to install the whole VS 2015 - just the sdk should work.
  • Note that the path may change in your case. I just pasted the path which worked for me.
  • Also, this is not a full and final solution to allow your regular .Net project to build with the latest VS 2017 tooling, it is just a solution to the above error.

As I said, there are still many things to do, so I will write some more posts in the future on these topics.

P.S. Start restructuring your normal csproj code to latest sdk structure, which will help you to onboard your applications with the latest powerful VS 2017 tools.

Helpful link: Old csproj to new csproj: Visual Studio 2017 upgrade guide.

Hope it helps.

Assembly (CLI) Framework Build (game engine)

Published at DZone with permission of Neel Bhatt. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Stateless vs. Stateful Widgets: Make the Right Choice for Your Flutter App
  • How to Build Your Own AI SRE From Scratch
  • AWS 7R Migration Strategies: A Decision Framework for Engineering Teams
  • Stop Preparing for Audits — Build the Pipeline That Audits Itself

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook