dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.06k forks source link

CRUD dotnet commands for MSBuild properties #7500

Open natemcmaster opened 7 years ago

natemcmaster commented 7 years ago

Would be nice if dotnet had commands to add/read/change/remove properties in an MSBuild file.

Example: dotnet prop set VersionSuffix beta Would update project to include, or would alter its value if it already exists

<PropertyGroup>
   <VersionSuffix>beta</VersionSuffix>
</PropertyGroup>

Example 2: Reading properties values.

$ dotnet prop get OutputType
Exe

Scenarios:

cc @blackdwarf

TheRealPiotrP commented 7 years ago

We won't get to this before RTM but it's something we should look at soon after. @blackdwarf @rainersigwald for their thoughts.

rainersigwald commented 7 years ago

My general feeling is that this is going to be very expensive for the benefit.

Important factors to consider:

natemcmaster commented 7 years ago

This is done in CPS

Could we abstract this into a class library?

rainersigwald commented 7 years ago

I don't think it's currently very well isolated, but there's nothing conceptually stopping such a thing. Just work.

muratg commented 7 years ago

@piotrpMSFT Any plans to get this done in 2.0 timeline?

blackdwarf commented 7 years ago

@muratg we don't have plans for this in the 2.0 timeline. After thinking about it for a while, I'm leaning towards agreeing with @rainersigwald. This command can only support the basic property adding without devolving into a very messy UX. I'm not sure that in those cases, and you can get into those cases pretty fast, you are not better off just cracking open the file and editing it.

natemcmaster commented 7 years ago

Could we start with "get" and do "set" later?

Almost all CLI tools need to read properties like OutputPath, AssemblyName, TargetFramework, etc. (dotnet-watch, dotnet-ef, dotnet-xunit to name a few)

Only a few of them need to edit a csproj. And there are simple solutions for this. For example, a CLI tool might simply print a message that says "Please add <xml here> to your csproj".

WeihanLi commented 3 years ago

Any update on this?