Skip to content

Instantly share code, notes, and snippets.

@kzu
Created June 16, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzu/7408cbf15d2971b62e62 to your computer and use it in GitHub Desktop.
Save kzu/7408cbf15d2971b62e62 to your computer and use it in GitHub Desktop.
MSBuild supports non-quoted strings in conditions
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<Message Condition="$(Message) != ''" Text="Message: $(Message)" />
</Target>
<Import Project="$(ProjectFile)" Condition="$(ProjectFile) != ''" />
</Project>
@kzu
Copy link
Author

kzu commented Jun 16, 2014

Behavior:

  • Run: msbuild test.proj -> nothing is done, no imports, no message
Build started 16/06/2014 03:53:22 p.m..

Build succeeded.
    0 Warning(s)
    0 Error(s)
  • Run: msbuild test.proj /p:Message=Hello:
Build started 16/06/2014 03:53:31 p.m..
Project "C:\Code\Personal\vsx\DynamicSolution\test.proj" on node 1 (default targets).
Build:
  Message: Hello
Done Building Project "C:\Code\Personal\vsx\DynamicSolution\test.proj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)
  • Run msbuild test.proj /p:Message=Hello /p:ProjectFile=Foo.proj
Build started 16/06/2014 03:53:38 p.m..
Project "C:\Code\Personal\vsx\DynamicSolution\test.proj" on node 1 (default targets).
C:\Code\Personal\vsx\DynamicSolution\test.proj(8,2): error MSB4019: The imported project "C:\Code\Personal\vsx\DynamicS
olution\Foo.proj" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists
 on disk.
Done Building Project "C:\Code\Personal\vsx\DynamicSolution\test.proj" (default targets) -- FAILED.


Build FAILED.

"C:\Code\Personal\vsx\DynamicSolution\test.proj" (default target) (1) ->
  C:\Code\Personal\vsx\DynamicSolution\test.proj(8,2): error MSB4019: The imported project "C:\Code\Personal\vsx\Dynami
cSolution\Foo.proj" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exis
ts on disk.

    0 Warning(s)
    1 Error(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment