DEV Community

Cover image for [Solution] MSBUILD Could not locate assembly
4 1

[Solution] MSBUILD Could not locate assembly

MSBuild is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.

Scenario:

I've a C# Windows Forms project .csproj that references some common dll´s.
These dll´s are coming from a folder outside project folder.
These dll´s are referenced at design time, from GAC (global assembly cache).

Problem:

When I´m building the project, inside a remote server, these dll´s should be searchable from another path.
Otherwise, I´ll receive the error below:

[warning]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2084,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "DevExpress.Charts.v20.1.Core". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Solution:

  1. Open .csprojfile
  2. Go to the final line, and before the tag, insert.
<Target Name="BeforeResolveReferences">
  <CreateProperty Value="$(MSBuildProjectDirectory)\two\levels\relativePath;$(AssemblySearchPaths)">
    <Output TaskParameter="Value" PropertyName="AssemblySearchPaths"/>
  </CreateProperty>
</Target>
Enter fullscreen mode Exit fullscreen mode
  1. Replace $(MSBuildProjectDirectory)\two\levels\relativePath; to your relative or absolute path.

References:

https://stackoverflow.com/questions/19309880/using-assemblysearchpaths-in-csproj-files/19456666
http://www.beefycode.com/post/resolving-binary-references-in-msbuild.aspx

Other references for deeper info:

https://docs.microsoft.com/en-us/visualstudio/msbuild/walkthrough-using-msbuild?view=vs-2019#targets-and-tasks
https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-2.0/9ad3f294(v=vs.80)?redirectedfrom=MSDN
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-reserved-and-well-known-properties?view=vs-2019

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay