dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.22k stars 1.35k forks source link

How to create multiple assets (dll) for one project with msbuild depend on Constans value? #5108

Open soroshsabz opened 4 years ago

soroshsabz commented 4 years ago

ITNOA

I have a question in stackoverflow but I think this place can make better for get better answer to my question.

I have Visual Studio 2019.

I know we can build one project with multiple configurations, and have a dll per configuration, for example we can have one dll for the Debug configuration of our project and we can have one dll for the Release configuration of our project.

But my question is how to have multiple dlls for one project based on DefineConstants, for example one dll when we <DefineConstants>ML_HOOSHANG</DefineConstants> and have another dll for this project without define this constant?

Another question is how to package this project with hold all of these dlls per definition of our define constants?

Another question is, can I force Visual Studio (msbuild) to generate all dlls per build request?

Is UsingTask useful for this purpose? or not?

Is there anyway to change DefineConstants per UsingTask?

Thanks a lot

dsplaisted commented 4 years ago

The standard way to do this would be to define additional configurations, and set different DefineConstants values for each configuration.

Another question is how to package this project with hold all of these dlls per definition of our define constants?

If you're talking about a NuGet package, you can have different NuGet package assets per target framework, but you can't make up your own asset groups for consumers to choose from manually.