diff options
author | Kinan Mahdi <kinan.mahdi@gmail.com> | 2019-05-28 14:21:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-05-30 14:22:44 (GMT) |
commit | 42e14d90b1b38df6c698ef230ab06ae9504436d5 (patch) | |
tree | 907c12d11cf00ff9b9c6feca55e9a4dbfa702299 /Source | |
parent | e13b18e2c70f42c23ed7e7fddb93557ce19b7359 (diff) | |
download | CMake-42e14d90b1b38df6c698ef230ab06ae9504436d5.zip CMake-42e14d90b1b38df6c698ef230ab06ae9504436d5.tar.gz CMake-42e14d90b1b38df6c698ef230ab06ae9504436d5.tar.bz2 |
VS: Added support for VS package references for nuget
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 3 |
2 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d328a8c..09821e9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -664,6 +664,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); @@ -737,6 +738,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; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 1dea8e9..cb6832b 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -72,6 +72,9 @@ private: void WriteExcludeFromBuild(Elem& e2, std::vector<size_t> const& exclude_configs); void WriteAllSources(Elem& e0); + void WritePackageReferences(Elem& e0); + void WritePackageReference(Elem& e1, std::string const& ref, + std::string const& version); void WriteDotNetReferences(Elem& e0); void WriteDotNetReference(Elem& e1, std::string const& ref, std::string const& hint, |