question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build with multiple constants

See original GitHub issue

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.

Actual behavior

MSB1006 “property not valid…” is thrown

Environment data

  • dotnet sdk 2.1.300
  • win7-x64

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
iotalambdacommented, Apr 23, 2020

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

1reaction
Keincommented, Jan 18, 2023

@CodeDux Clever, I’m stealing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing define constants to dotnet build kills target ...
I created a small application which targets two frameworks (.net core 2.2 and .net core 3.0) and uses target framework symbols (NETCOREAPP2_2 ...
Read more >
dotnet build command - .NET CLI
The dotnet build command builds the project and its dependencies into a set of binaries. The binaries include the project's code in ...
Read more >
C# preprocessor directive symbols from the dotnet build ...
The "DefineConstants" property is a global property, and cannot be modified. Instead one has to employ a little indirection. In your csproj file ......
Read more >
Environment Variables
Defining Multiple Variables per Item #. If you need to specify several environment variables for each build, put them all on the same...
Read more >
C# 8.0 and .NET Core 3.0 – Modern Cross-Platform ...
Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code Mark J. Price. 2. Create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found