简体   繁体   English

如何将构建属性传递给dotnet?

[英]How to pass build properties to dotnet?

In my C# and .net core program, I want to dynamically select dependency by using properties in the .csproj file. 在我的C#和.net核心程序中,我想通过使用.csproj文件中的属性来动态选择依赖项。 I learned from online that I can supply those properties while using the msbuild command. 我从在线中学到了可以使用msbuild命令提供这些属性。 However, I am using dotnet. 但是,我正在使用dotnet。 How then can I supply those flags? 那我该如何提供这些标志呢?

I can see the confusion arises due to a misunderstanding of the relationship of msbuild and dotnet. 我可以看到由于对msbuild和dotnet关系的误解而引起的混乱。 dotnet is a wrapper of tools such as nuget and msbuild. dotnet是nuget和msbuild等工具的包装。 As per the doc, 根据文档,

the dotnet build command accepts MSBuild options, such as /p for setting properties or /l to define a logger. dotnet build命令接受MSBuild选项,例如/ p设置属性或/ l定义记录器。

you can supply msbuild property like so: 您可以提供msbuild属性,如下所示:

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. 但是要小心,如果在linux或mac上使用它,则在使用“;”提供多个属性时,应引用整个/ p标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM