Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core - build project specifying ReferencePath

I have a .csproj for the .NetCore platform with classic references. I'm using the hintpath attribute for the development environment. But I should build csproj on the CI-environment where referenced assemblies are placed in the different directory. On the classic net4 I've used the /p:ReferencePath argument for the MSBuild tool. But the "dotnet build" has no similar argument. As a fallback I found the "dotnet msbuild" command but this tool is ignores the /p:ReferencePath=xxx argument and shows me

warning MSB3245: Could not resolve this reference. Could not locate the assembly "AssemblyName". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Please guide me, what can I check, where dotnet-build/dotnet-msbuild tools are searching the referenced assemblies and how to specify that directory?

like image 567
k0st1x Avatar asked Apr 27 '18 07:04

k0st1x


People also ask

How to add csproj as Reference?

Add Project References Data project. Alternatively to adding the project reference via the command line - you could also just type that into the . csproj file. Copy the project reference down two more times and edit them to add references to the Models, Data, Contracts, and Services class libraries.

How do I add a project reference in NET Core project?

One method of adding references to your library is by typing it directly in the project. json file. As you can see that we have added some references under the dependencies section as shown in the following code. Let us now save this file and you will see that references are added to your library now.

What is .NET Core in C#?

NET Core is a modular, cross-platform, and open source software development framework that is used to build Windows, Web, and Mobile applications for Windows, Linux and OS X platforms.


1 Answers

Problem is coused by Microsoft.NET.Sdk.props: AssemblySearchPaths has no ReferencePath. Fixed by adding to csproj:

<PropertyGroup>
    <AssemblySearchPaths>
        $(AssemblySearchPaths);
        $(ReferencePath);
    </AssemblySearchPaths>
</PropertyGroup>
like image 164
Dmitry C Avatar answered Sep 29 '22 16:09

Dmitry C