如何将构建属性传递给dotnet? [英] How to pass build properties to dotnet?
问题描述
在我的C#和.net核心程序中,我想通过使用.csproj文件中的属性来动态选择依赖项.我从网上了解到,使用msbuild命令时可以提供这些属性.但是,我正在使用dotnet.那我该如何提供这些标志呢?
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?
推荐答案
我可以看到由于对msbuild和dotnet关系的误解而引起的混乱.dotnet是nuget和msbuild等工具的包装.根据文档,
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,
dotnet build命令接受MSBuild选项,例如/p设置属性或/l来定义记录器.
the dotnet build command accepts MSBuild options, such as /p for setting properties or /l to define a logger.
您可以像这样提供msbuild属性:
you can supply msbuild property like so:
dotnet build /p:property0=val0;property1=val1
但是请注意,如果您在linux或mac上使用它,则在使用;"提供多个属性时,应引用整个/p标志.
Be careful though, if you are using this on linux or mac, when supplying multiple properties using ";", you should quote the entire /p flag.
这篇关于如何将构建属性传递给dotnet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!