Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass build properties to dotnet?

Tags:

c#

.net

In my C# and .net core program, I want to dynamically select dependency by using properties in the .csproj file. I learned from online that I can supply those properties while using the msbuild command. However, I am using dotnet. How then can I supply those flags?

like image 643
Closed Chair Avatar asked Jul 23 '18 18:07

Closed Chair


1 Answers

I can see the confusion arises due to a misunderstanding of the relationship of msbuild and dotnet. dotnet is a wrapper of tools such as nuget and msbuild. As per the doc,

the dotnet build command accepts MSBuild options, such as /p for setting properties or /l to define a logger.

you can supply msbuild property like so:

dotnet build /p:property0=val0;property1=val1

Be careful though, if you are using this on linux or mac, when supplying multiple properties using ";", you should quote the entire /p flag.

like image 161
Mong H. Ng Avatar answered Sep 20 '22 13:09

Mong H. Ng