Hello,
I have a newly created f# netcoreapp2.1 console app with a vanilla fsproj file. I want to pass multiple constants to dotnet build. This works and the constants are validated when I run the program:
msbuild /p:DefineConstants="HELLO;WORLD"
... but this fails with MSB1006 errors:
dotnet build /p:DefineConstants="HELLO;WORLD"
dotnet build /p:DefineConstants=HELLO;WORLD
dotnet build /p:DefineConstants=\"Hello,World\"
dotnet build /p:DefineConstants=\"Hello;World\"
dotnet build /p:DefineConstants='Hello;World'
(...)
Is there a way to make this work with dotnet build cli? Thanks for the help.
MSB1006 "property not valid..." is thrown
Hi @HeinzmeierDornbuschFeldhausen,
Could you try dotnet build /p:DefineConstants=\"HELLO;WORLD\"
? Note the backslashes around the double quote characters, which escapes them down to MSBuild. MSBuild uses the double quotes around the property value to treat characters like ;
as literal values, rather than the command-line syntax to define multiple properties in a single option (e.g. /p:First=Foo;Second=Bar
which sets First
to Foo
and Second
to Bar
).
Thanks!
@HeinzmeierDornbuschFeldhausen I'm going to close this issue for now; please re-open if using the escaped quotes above does not have the desired effect.
Thanks for reporting this issue!
I faced the same issue and the only working solution seems to be to escape the ;
with %3B
. E.g:
dotnet clean; dotnet build "/p:DefineConstants=HELLO%3BWORLD"; dotnet run --no-build
@peterhuene is using %3B
the correct way to do this? I could not find documentation for that. Could someone reopen this if there is no documentation for this solution or until a fix is in place if this is not the desirable solution? Thank you.
I have tested this in my app and found using %3B also fixed it. This seems like a bug, or at least poor documentation. (I use a build script so my command is like dotnet publish ..\ALOTInstallerWPF.csproj -c Release --output Staging\ALOTInstallerWPF /p:DebugType=embedded /p:PublishSingleFile=true /p:PublishTrimmed=true /p:DefineConstants=WINDOWS;WPF --runtime win-x64
and shows failure on 'switch WPF'.
using %3B was the only thing that worked for me as well. Thanks for that, have spent an hour on this thing.
It worked for me with my vbproj also, using %2C
(,
) instead of %3B
like below:
dotnet build /p:DefineConstants=FOO%2CBAR%2CBAZ test.vbproj
Most helpful comment
I faced the same issue and the only working solution seems to be to escape the
;
with%3B
. E.g:dotnet clean; dotnet build "/p:DefineConstants=HELLO%3BWORLD"; dotnet run --no-build