Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# reference in .props file

When I add this code directly to the .csproj file, the reference is resolved correctly:

<ItemGroup>
  <Reference Include="base_csharp">
    <HintPath>D:\Repositories\MDSBuild\MdsDrivers\deps\Base\install\bin\Windows\MSVC\x86\Debug\base_csharp.dll</HintPath>
  </Reference>
</ItemGroup>

However, when I put the exact same code in a props file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Reference Include="base_csharp">
      <HintPath>D:\Repositories\MDSBuild\MdsDrivers\deps\Base\install\bin\Windows\MSVC\x86\Debug\base_csharp.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
</Project>

And import that props file into the .csproj

<Import Project="D:\Repositories\MDSBuild\MdsDrivers\deps\Base\scripts\props\base_csharp.props" /

I get the warning that the reference could not be resolved:

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

The code is exactly the same and all the paths are absolute, but for some inexplicable reason it is unable to find the .dll file. What am I doing wrong?

like image 901
Rick de Water Avatar asked Jun 28 '26 17:06

Rick de Water


1 Answers

One problem is that you have opened 2 "ItemGroup" tags and closed only one.

If your path is absolute you can give it like this:

<ItemGroup>
        <Reference Include= "D:\Repositories\MDSBuild\MdsDrivers\deps\Base\install\bin\Windows\MSVC\x86\Debug\base_csharp.dll" />
</ItemGroup>
like image 169
sowmya dantuluri Avatar answered Jul 01 '26 06:07

sowmya dantuluri