diff options
author | Sumit Bhardwaj <bhardwajs@outlook.com> | 2021-12-15 16:21:34 (GMT) |
---|---|---|
committer | Sumit Bhardwaj <bhardwajs@outlook.com> | 2021-12-21 17:35:49 (GMT) |
commit | 0eea32a376fc54b198fa4690ca57b829a2d14baa (patch) | |
tree | c786935ed240c0857c0e82d87ffc27149fdade33 /Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake | |
parent | a450cc9533ac8a54d14ec5e0cbf6b379a2014e7a (diff) | |
download | CMake-0eea32a376fc54b198fa4690ca57b829a2d14baa.zip CMake-0eea32a376fc54b198fa4690ca57b829a2d14baa.tar.gz CMake-0eea32a376fc54b198fa4690ca57b829a2d14baa.tar.bz2 |
VS: Add DOTNET_SDK property to generate SDK-style C# projects
Changes in cmVisualStudio10TargetGenerator::Generate to write .Net
SDK-style project for VS generators VS 19 and above. Also adds
documentation and tests.
Issue: #20227
Diffstat (limited to 'Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake')
-rw-r--r-- | Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake b/Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake new file mode 100644 index 0000000..7a5cd1d --- /dev/null +++ b/Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake @@ -0,0 +1,52 @@ +set(files foo.csproj bar.csproj baz.csproj) + +set(inLib1 FALSE) +set(dotnetSdkInLib1 FALSE) + +set(inLib2 FALSE) +set(dotnetSdkWebInLib2 FALSE) + +set(inLib3 FALSE) +set(classicProjInLib3 FALSE) + +foreach(file ${files}) + set(csProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() + endif() + + file(STRINGS "${csProjectFile}" lines) + + foreach(line IN LISTS lines) + if(NOT inLib1) + if(line MATCHES "<Project Sdk=\"Microsoft\.NET\.Sdk\">") + set(dotnetSdkInLib1 TRUE) + set(inLib1 TRUE) + endif() + elseif(NOT inLib2) + if(line MATCHES "<Project Sdk=\"Microsoft\.NET\.Sdk\.Web\">") + set(dotnetSdkWebInLib2 TRUE) + set(inLib2 TRUE) + endif() + elseif(NOT inLib3) + if(line MATCHES "<Project DefaultTargets=\"Build\" ToolsVersion=\"") + set(classicProjInLib3 TRUE) + set(inLib3 TRUE) + endif() + endif() + endforeach() +endforeach() + +if(NOT dotnetSdkInLib1) + set(RunCMake_TEST_FAILED ".Net SDK not set correctly.") +endif() + +if(NOT dotnetSdkWebInLib2) + set(RunCMake_TEST_FAILED ".Net Web SDK not set correctly.") +endif() + +if(NOT classicProjInLib3) + set(RunCMake_TEST_FAILED "Empty DOTNET_SDK doesn't build Classic project.") +endif() |