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.66k stars 1.06k forks source link

[Feature Request]: warn if a pack-target assembly property is set but GenerateAssemblyInfo is False #41770

Open ericsampson opened 2 months ago

ericsampson commented 2 months ago

Summary

Add a warning to help users diagnose a scenario where setting assembly properties is getting "ignored".

Background and Motivation

As a scenario: a large legacy solution has been migrated to the .SDK format, and in some obscure project(s) a previous developer has set GenerateAssemblyInfo to False so that an AssemblyInfo.cs file is being used.

At a later time a different developer sets Assembly-related properties via dotnet/msbuild CLI args or Directory.Build.props, and cannot figure out why those properties are getting ignored for some projects. There's no warning printed to the command line, and even creating a binlog and loading it into the binlog viewer doesn't give any hints about why the property settings are getting "ignored" for those assemblies.

Proposed Feature

If GenerateAssemblyInfo is false, then emit a warning if any pack-target properties are set. (I suppose this would also apply to any of the individual GenerateAssembly*Attribute properties, but that might be getting into pretty rare scenarios 🤷)

Alternative Designs

?

baronfel commented 2 months ago

I'm going to move this to dotnet/sdk because all of the AssemblyInfo generation logic is provided by the SDK.