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.23k stars 1.35k forks source link

Question : How to pass msbuild properties to child msbuild tasks cleanly ? #3363

Open ashishnegi opened 6 years ago

ashishnegi commented 6 years ago

I have not added repro steps as this is more of a question than a bug. Please let me know if i still need to add a sample project.

I have 10 properties that i set with command line arguments for msbuild. I have few <MSBuild> task in my csproj where i need to forward these properties.

If i have to add another property MyProperty11, i have to go modify all these MSBuild task to correctly forward the properties.

Is there a simpler & cleaner way to forward properties ? How can i capture all the properties passed to parent msbuild task and forward to children msbuild tasks.

Command line

dotnet msbuild /p:MyProperty1=MyValue1 /p:MyProperty2=MyValue2 ...
asnegi@asnegi-vm $ dotnet msbuild /version
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

15.4.8.50001

OS info:

Both windows and Linux.

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):

$ dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
 Version:            2.0.3
 Commit SHA-1 hash:  eb1d5ee318

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.3/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11
ashishnegi commented 6 years ago

Suggestions ?