VsCSharpDeployFiles-check.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
  2. if(NOT EXISTS "${csProjectFile}")
  3. set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
  4. return()
  5. endif()
  6. set(inNode1 FALSE)
  7. set(foundNode1 FALSE)
  8. set(foundCopyDirective1 FALSE)
  9. set(inNode2 FALSE)
  10. set(foundNode2 FALSE)
  11. set(foundCopyDirective2 FALSE)
  12. set(foundNode3 FALSE)
  13. file(STRINGS "${csProjectFile}" lines)
  14. foreach(line IN LISTS lines)
  15. if( inNode1 )
  16. if(line MATCHES " *<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> *$")
  17. set(foundCopyDirective1 TRUE)
  18. elseif( line MATCHES " *</Content> *$")
  19. set(inNode1 FALSE)
  20. endif()
  21. elseif( inNode2 )
  22. if(line MATCHES " *<CopyToOutputDirectory>Always</CopyToOutputDirectory> *$")
  23. set(foundCopyDirective2 TRUE)
  24. elseif( line MATCHES " *</Content> *$")
  25. set(inNode2 FALSE)
  26. endif()
  27. elseif(line MATCHES "^ *<Content *Include *= *\".*content1\\.txt\"> *")
  28. set(foundNode1 TRUE)
  29. set(inNode1 TRUE)
  30. elseif(line MATCHES "^ *<Content *Include *= *\".*content2\\.txt\"> *")
  31. set(foundNode2 TRUE)
  32. set(inNode2 TRUE)
  33. elseif(line MATCHES "^ *<None *Include *= *\".*content3\\.txt\"> *")
  34. set(foundNode3 TRUE)
  35. endif()
  36. endforeach()
  37. if(NOT foundNode1)
  38. set(RunCMake_TEST_FAILED "Did not find <Content> item content1.txt.")
  39. return()
  40. endif()
  41. if(NOT foundCopyDirective1)
  42. set(RunCMake_TEST_FAILED "Did not find PreserveNewest for <Content> item content1.txt.")
  43. return()
  44. endif()
  45. if(NOT foundNode2)
  46. set(RunCMake_TEST_FAILED "Did not find <Content> item content2.txt.")
  47. return()
  48. endif()
  49. if(NOT foundCopyDirective2)
  50. set(RunCMake_TEST_FAILED "Did not find Always for <Content> item content2.txt.")
  51. return()
  52. endif()
  53. if(NOT foundNode3)
  54. set(RunCMake_TEST_FAILED "Did not find <None> item content3.txt.")
  55. return()
  56. endif()