diff options
author | Brad King <brad.king@kitware.com> | 2019-05-31 17:18:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-05-31 17:18:31 (GMT) |
commit | 187928875d215df8757b291ad629a36df75da42b (patch) | |
tree | 320f5369e8d6d9c3b7eed592c079e6c6f849e99c /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 66bba23a4b4c6e7901524677f245d02a31b3eff8 (diff) | |
parent | 42e14d90b1b38df6c698ef230ab06ae9504436d5 (diff) | |
download | CMake-187928875d215df8757b291ad629a36df75da42b.zip CMake-187928875d215df8757b291ad629a36df75da42b.tar.gz CMake-187928875d215df8757b291ad629a36df75da42b.tar.bz2 |
Merge topic 'vs-add-package-reference'
42e14d90b1 VS: Added support for VS package references for nuget
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Leonid Pospelov <pospelovlm@yandex.ru>
Merge-request: !3389
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 3db3813..9368414 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -665,6 +665,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(e0); this->WriteAllSources(e0); this->WriteDotNetReferences(e0); + this->WritePackageReferences(e0); this->WriteImports(e0); this->WriteEmbeddedResourceGroup(e0); this->WriteXamlFilesGroup(e0); @@ -738,6 +739,33 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteGroups(); } +void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) +{ + std::vector<std::string> packageReferences; + if (const char* vsPackageReferences = + this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) { + cmSystemTools::ExpandListArgument(vsPackageReferences, packageReferences); + } + if (!packageReferences.empty()) { + Elem e1(e0, "ItemGroup"); + for (std::string const& ri : packageReferences) { + size_t versionIndex = ri.find_last_of('_'); + if (versionIndex != std::string::npos) { + WritePackageReference(e1, ri.substr(0, versionIndex), + ri.substr(versionIndex + 1)); + } + } + } +} + +void cmVisualStudio10TargetGenerator::WritePackageReference( + Elem& e1, std::string const& ref, std::string const& version) +{ + Elem e2(e1, "PackageReference"); + e2.Attribute("Include", ref); + e2.Attribute("Version", version); +} + void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) { std::vector<std::string> references; |