MCPcopy Create free account
hub / github.com/Kitware/CMake / WriteSdkStyleProjectFile

Method WriteSdkStyleProjectFile

Source/cmVisualStudio10TargetGenerator.cxx:914–1035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912}
913
914void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
915 cmGeneratedFileStream& BuildFileStream)
916{
917 if (this->ProjectType != VsProjectType::csproj ||
918 !this->GeneratorTarget->IsDotNetSdkTarget()) {
919 std::string message =
920 cmStrCat("The target \"", this->GeneratorTarget->GetName(),
921 "\" is not eligible for .Net SDK style project.");
922 this->Makefile->IssueMessage(MessageType::INTERNAL_ERROR, message);
923 return;
924 }
925
926 Elem e0(BuildFileStream, "Project");
927 e0.Attribute("Sdk", *this->GeneratorTarget->GetProperty("DOTNET_SDK"));
928
929 {
930 Elem e1(e0, "PropertyGroup");
931 this->WriteCommonPropertyGroupGlobals(e1);
932
933 e1.Element("Configurations", cmJoinStrings(this->Configurations, ";", ""));
934
935 e1.Element("EnableDefaultItems", "false");
936 // Disable the project upgrade prompt that is displayed the first time a
937 // project using an older toolset version is opened in a newer version
938 // of the IDE.
939 e1.Element("VCProjectUpgraderObjectName", "NoUpgrade");
940 e1.Element("ManagedAssembly", "true");
941
942 cmValue targetFramework =
943 this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
944 if (targetFramework) {
945 if (targetFramework->find(';') != std::string::npos) {
946 e1.Element("TargetFrameworks", *targetFramework);
947 } else {
948 e1.Element("TargetFramework", *targetFramework);
949 e1.Element("AppendTargetFrameworkToOutputPath", "false");
950 }
951 } else {
952 e1.Element("TargetFramework", "net5.0");
953 e1.Element("AppendTargetFrameworkToOutputPath", "false");
954 }
955
956 std::string outputType;
957 switch (this->GeneratorTarget->GetType()) {
958 case cmStateEnums::OBJECT_LIBRARY:
959 case cmStateEnums::STATIC_LIBRARY:
960 case cmStateEnums::MODULE_LIBRARY:
961 this->Makefile->IssueMessage(
962 MessageType::FATAL_ERROR,
963 cmStrCat("Target \"", this->GeneratorTarget->GetName(),
964 "\" is of a type not supported for managed binaries."));
965 return;
966 case cmStateEnums::SHARED_LIBRARY:
967 outputType = "Library";
968 break;
969 case cmStateEnums::EXECUTABLE: {
970 auto const win32 =
971 this->GeneratorTarget->GetSafeProperty("WIN32_EXECUTABLE");

Callers 1

GenerateMethod · 0.95

Calls 15

WriteSdkStyleEventsMethod · 0.95
WriteCustomCommandsMethod · 0.95
WriteAllSourcesMethod · 0.95
WriteXamlFilesGroupMethod · 0.95
WriteDotNetReferencesMethod · 0.95
WriteImportsMethod · 0.95
cmJoinStringsFunction · 0.85

Tested by

no test coverage detected