Friday, March 27, 2020

Deal with AssemblyInfo.cs duplicate attributes when porting a C# class library from .NET Framework to .NET Core.

\obj\Debug\netcoreapp3.1\MyApp.AssemblyInfo.cs may be cranky complaining of dupes for AssemblyCompanyAttribute, AssemblyConfigurationAttribute, AssemblyFileVersionAttribute, AssemblyProductAttribute, AssemblyTitleAttribute, and AssemblyVersionAttribute. This suggests changing the .csproj file for the project having a blob like so...

<PropertyGroup>
   <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

 
 

Change it up like so:

<PropertyGroup>
   <TargetFramework>netcoreapp3.1</TargetFramework>
   <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
   <GenerateAssemblyConfigurationAttribute>false
         </GenerateAssemblyConfigurationAttribute>
   <GenerateAssemblyFileVersionAttribute>false
         </GenerateAssemblyFileVersionAttribute>
   <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
   <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
   <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>

 
 

Addendum 3/30/2020: \obj\Debug\netcoreapp3.1\MyApp.AssemblyInfo.cs may be cranky complaining of dupes for AssemblyCompanyAttribute, AssemblyConfigurationAttribute, AssemblyFileVersionAttribute, AssemblyProductAttribute, AssemblyTitleAttribute, and AssemblyVersionAttribute. above should read \obj\Debug\netcoreapp3.1\MyApp.AssemblyInfo.cs may be cranky complaining of dupes for AssemblyCompany, AssemblyConfiguration, AssemblyFileVersion, AssemblyProduct, AssemblyTitle, and AssemblyVersion.

No comments:

Post a Comment