Visual studio add project reference with lib file

630 Views Asked by At

It looks like there has been some work done to add support for visual studio c++ project to project references.

https://developercommunity.visualstudio.com/t/MsBuild-to-resolve-and-copy-ProjectRefer/668834?space=62

If I setup a reference from GoogleTestSample to oqkern I am able to get a bunch of files copied locally. oqkern.net.dll oqkern.net.runtimeconfig.json and also a bunch of other dlls

enter image description here

Is there a way I can get the oqkern.net.lib file to be copied locally as well?

I seem to need that to be able to compile without getting linker errors.

I think the property below takes care of being able to include source files from the referenced project:

enter image description here

I have tried to use the "content file" approach but it didn't seem to work.

  <ItemGroup>
    <Library Include="..\..\src\oqkern\bin\$(Platform)\$(Configuration)\oqkern.net.lib">
      <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
      <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
    </Library>
  </ItemGroup>

I'm not sure if the content file approach happens soon enough, I need the file copied before the build so things compile.

A pre-build event works:

xcopy /y /d  "$(SolutionDir)src\oqkern\bin\$(Platform)\$(Configuration)\oqkern.net.lib" "$(OutDir)"
0

There are 0 best solutions below