VS: Add support for .NET Standard and .NET Core

Fixes: #20105
This commit is contained in:
Joerg Bornemann
2020-01-13 17:33:55 +01:00
committed by Brad King
parent 93d4148612
commit ae1e1909a1
18 changed files with 216 additions and 23 deletions
+30 -17
View File
@@ -483,23 +483,33 @@ void cmVisualStudio10TargetGenerator::Generate()
}
e1.Element("ProjectName", projLabel);
{
// TODO: add deprecation warning for VS_* property?
const char* targetFrameworkVersion =
this->GeneratorTarget->GetProperty(
"VS_DOTNET_TARGET_FRAMEWORK_VERSION");
if (!targetFrameworkVersion) {
targetFrameworkVersion = this->GeneratorTarget->GetProperty(
"DOTNET_TARGET_FRAMEWORK_VERSION");
}
if (!targetFrameworkVersion && this->ProjectType == csproj &&
this->GlobalGenerator->TargetsWindowsCE() &&
this->GlobalGenerator->GetVersion() ==
cmGlobalVisualStudioGenerator::VS12) {
// VS12 .NETCF default to .NET framework 3.9
targetFrameworkVersion = "v3.9";
}
if (targetFrameworkVersion) {
e1.Element("TargetFrameworkVersion", targetFrameworkVersion);
const char* targetFramework =
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
if (targetFramework) {
if (std::strchr(targetFramework, ';') != nullptr) {
e1.Element("TargetFrameworks", targetFramework);
} else {
e1.Element("TargetFramework", targetFramework);
}
} else {
// TODO: add deprecation warning for VS_* property?
const char* targetFrameworkVersion =
this->GeneratorTarget->GetProperty(
"VS_DOTNET_TARGET_FRAMEWORK_VERSION");
if (!targetFrameworkVersion) {
targetFrameworkVersion = this->GeneratorTarget->GetProperty(
"DOTNET_TARGET_FRAMEWORK_VERSION");
}
if (!targetFrameworkVersion && this->ProjectType == csproj &&
this->GlobalGenerator->TargetsWindowsCE() &&
this->GlobalGenerator->GetVersion() ==
cmGlobalVisualStudioGenerator::VS12) {
// VS12 .NETCF default to .NET framework 3.9
targetFrameworkVersion = "v3.9";
}
if (targetFrameworkVersion) {
e1.Element("TargetFrameworkVersion", targetFrameworkVersion);
}
}
if (this->ProjectType == vcxproj &&
this->GlobalGenerator->TargetsWindowsCE()) {
@@ -4110,6 +4120,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
e2.Element("Project", "{" + this->GlobalGenerator->GetGUID(name) + "}");
e2.Element("Name", name);
this->WriteDotNetReferenceCustomTags(e2, name);
if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) {
e2.Element("SkipGetTargetFrameworkProperties", "true");
}
// Don't reference targets that don't produce any output.
if (dt->GetManagedType("") == cmGeneratorTarget::ManagedType::Undefined) {