I am using GitVersion in my WPF-project. When publishing my app I use profile setting Produce single file which I want to stick to. Publish only runs successfully if I set im my .csproj-file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
</Project>
I also have set the Copyright information in my .csproj-file:
<Copyright>Copyright © ...</Copyright>
With GenerateAssemblyInfo set to true I can read the Copyright attribute in my code by reflection:
var copyRightAttribute = (AssemblyCopyrightAttribute)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(AssemblyCopyrightAttribute));
Also in file-details it is visible:
How can I have all at the same time?
When you disable automatic AssemblyInfo
generation,
then you will need to include an AssemblyInfo.cs
file yourself into your project,
holding the AssemblyCopyrightAttribute
and others.
The ones in the .csproj
file will not be considered anymore when it contains an <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
.
Note that this also includes the version numbers and more.
An AssemblyInfo.cs
example:
using System.Reflection;
[assembly: AssemblyCopyright("Your Copyright Goes Here")]
[assembly: AssemblyTitle("Your Title")]
[assembly: AssemblyDescription("Your Description")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]