summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VsDotnetSdk/DotnetSdkVariables-check.cmake
blob: 7a5cd1d789cf09e3fb8c64b5c509ff7c271d0885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()