[CMake] Referencing nuget packages in csharp csproj files

Joern Hauser joern.hauser at sevencs.com
Tue Jan 30 04:55:53 EST 2018


Hello,

we're looking into generating our C# projects using CMAKE. We can generate working solution files, but we're still struggling with dependencies. We would like to manage nuget packages via the nuget.exe command line tool. With the install or restore parameter this deems us a good approach for managing dependencies. However, CMAKE currently only supports the Reference tag in the csproj file. Without an additional HintPath subtag into the package's folder the reference is not resolved. This HintPath points down the whole path to the DLL of the package, including version etc. So far I have not found a way how to extract this path from nuget.exe and I would not like having to guess it to fill the HintPath tag.

Any ideas how to solve this issue?

We found that using the new PackageReference tag (new since VS2017) would work fine without a HintPath and would offer complete configuration of dependencies via nuget.

So we wondered if CMAKE could support this new PackageReference tag, too, like it does for the Reference tag by means of the VS_DOTNET_REFERENCES? Or is there any way how we could inject the XML into the generated csproj file ourselves from the project's CMakeLists.txt? Looking into the CMAKE source code, I think supporting the PackageReference tag would basically require going along the lines of the VS_DOTNET_REFERENCES property handling. However, I don't know if another property like this (e.g. VS_DOTNET_PACKAGEREFERENCES) would be appreciated by the CMAKE team or whether there are better solutions? If such a property were acceptable maybe we could even try to offer a patch for CMAKE.

Thank you!

Cheers,
Jörn



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180130/42d5639f/attachment.html>


More information about the CMake mailing list