<div dir="ltr">Joern,<div><br></div><div>We too have been trying to find better integration between CMake and NuGet. What we have done is taken advantage of the packages.config file and the nuget.exe command line too. We have a custom target that executes `nuget restore` against the generated solution file. This by default places all the nuget packages in a packages directory under the build directory. It also updates all the references in the generate csproj files to the point to the packages directory. It works pretty good and does a great job of download dependencies when taking the sources to a new machine. </div><div><br></div><div>It would be nice though to have a way to specify the dependencies in the CMake file and have it fetch and explode them like nuget does and generate the correct csproj upfront. </div><div><br></div><div>Here is some snippets from our CMakeLists.txt:</div><div><br></div><div><div>find_program(NUGET nuget)</div><div>add_custom_target(nuget-restore </div><div> COMMAND ${NUGET} restore ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.sln</div><div>)</div><div><br></div></div><div>configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages.config ${CMAKE_CURRENT_BINARY_DIR}/packages.config COPYONLY)<br></div><div><br></div><div><div>set_target_properties( ${PROJECT_NAME} PROPERTIES</div><div> VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME}</div><div> VS_GLOBAL_ProjectGuid "{f84e584d-a422-3021-a20c-cec777413cae}"</div><div> VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2"</div><div> VS_DOTNET_REFERENCES "System;System.Xml;System.Web;System.Configuration;System.Xml.Linq"</div><div>)<br></div></div><div><br></div><div><div>add_dependencies(${PROJECT_NAME} nuget-restore)</div><div><br></div></div><div>-Jake</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 30, 2018 at 2:02 AM Joern Hauser <<a href="mailto:joern.hauser@sevencs.com">joern.hauser@sevencs.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="DE" link="blue" vlink="purple">
<div class="m_7498385090145199206WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hello,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">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.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Any ideas how to solve this issue? <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">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.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">So we wondered if CMAKE could support this new PackageReference tag, too, like it does for the Reference tag by means of the
<span class="m_7498385090145199206msgfragment">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.<u></u><u></u></span></span></p>
<p class="MsoNormal"><span class="m_7498385090145199206msgfragment"><span lang="EN-US"><u></u> <u></u></span></span></p>
<p class="MsoNormal"><span class="m_7498385090145199206msgfragment"><span lang="EN-US">Thank you!<u></u><u></u></span></span></p>
<p class="MsoNormal"><span class="m_7498385090145199206msgfragment"><span lang="EN-US"><u></u> <u></u></span></span></p>
<p class="MsoNormal"><span class="m_7498385090145199206msgfragment"><span lang="EN-US">Cheers,<u></u><u></u></span></span></p>
<p class="MsoNormal"><span class="m_7498385090145199206msgfragment"><span lang="EN-US">Jörn</span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>