Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a mechanism to control the AssemblyFileVersion independently from AssemblyVersion in MsBuild? #1450

Closed
ghost opened this issue Jul 25, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Jul 25, 2017

Hi

We are trying to save consumer frameworks and users the hassle of having to add assembly binding redirects when they upgrade minor/patch versions of Castle Core used as transitive dependencies. The issue where we are exploring this is here.

In summary this is what we landed on:

@stakx -> This line in Microsoft.NET.GenerateAssemblyInfo.targets suggests that it might be possible to add a <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> to the .csproj, then define that attribute manually. I haven't tried it myself, though. (If that doesn't work, then try the much coarser-grained <GenerateAssemblyInfo>false</GenerateAssemblyInfo>. I've used this before and it works, but it means you might then have to keep certain attributes in Castle.Core.csproj and AssemblyInfo.cs in sync manually.)

Is there a tidy way we can achieve this without adding an AssemblyInfo.cs?

Thanks

@dasMulli
Copy link
Contributor

dasMulli commented Aug 1, 2017

You can set the properties AssemblyVersion (=> AssemblyVersionAttribute) and FileVersion (=> AssemblyFileVersionAttribute) in the project file to control the value of each generated attribute.

So a sample project file could contain for example:

<PropertyGroup>
  <!-- Set VersionPrefix instead of Version to allow a suffix to be added by CI builds -->
  <VersionPrefix>1.2.3</VersionPrefix>
  <AssemblyVersion>1.2.0</AssemblyVersion>
  <FileVersion>$(VersionPrefix)</FileVersion>
</PropertyGroup>

@ghost
Copy link
Author

ghost commented Aug 1, 2017

@dasMulli - Many thanks :)

@ghost ghost closed this as completed Aug 1, 2017
@abatishchev
Copy link

Is it possible to disable the generation only of some parameters (those winch control versions) since a separate AssemblyInfo.cs is generated as part of my build? So I'm either turning off the generation of all attributes (those which control names) or I have only versions and rest are blank.

@dasMulli
Copy link
Contributor

Yes each attribute can be controlled individually by setting

<PropertyGroup>
  <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>

The pattern is Generate{AttributeName}Attribute, if you don't mind reading msbuild code the full list is here.

@abatishchev
Copy link

Awesome, thanks!

mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…0200511.11 (dotnet#1450)

- Microsoft.AspNetCore.Analyzers: 5.0.0-preview.5.20260.1 -> 5.0.0-preview.6.20261.11
- Microsoft.AspNetCore.Mvc.Analyzers: 5.0.0-preview.5.20260.1 -> 5.0.0-preview.6.20261.11
- Microsoft.AspNetCore.Components.Analyzers: 5.0.0-preview.5.20260.1 -> 5.0.0-preview.6.20261.11
- Microsoft.AspNetCore.Mvc.Api.Analyzers: 5.0.0-preview.5.20260.1 -> 5.0.0-preview.6.20261.11

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants