dotnet pack does not respect assembly atttributes
See original GitHub issue@junalmeida commented on Tue Jan 09 2018
Issue Title
Compiling and packing using Visual Studio 2017 or dotnet pack does not respect assembly attributes while using AssemblyInfo.cs
General
Using the following csproj structure:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Alma.Core</AssemblyName>
<RootNamespace>Alma.Core</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
When building the project, binaries are generated correctly with my attributes from .cs file, but nuget package is wrong:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Package version is always 1.0.0 with dotnet pack
Turns out, project.json was replaced with an updated .csproj file. I've updated my CI. During my CI - I update my /Properties/AssemblyInfo.
Read more >Create a NuGet package using MSBuild
NET Standard projects, and to non-SDK-style projects that use PackageReference. Set properties. The following properties are required to create ...
Read more >NuGet Error NU5026
Issue. The project being packed has not been built yet and hence cannot be packed. Solution. Please build the project before running ...
Read more >NuGet pack and restore as MSBuild targets
NET projects that use the PackageReference format, using msbuild -t:pack draws inputs from the project file to use in creating a NuGet package....
Read more >NuGet Package Version Reference
The highest version respecting the pattern and including the not stable versions. Available in Visual Studio version 16.6, NuGet version 5.6, .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
msbuild-integrated NuGet takes its version from the
PackageVersion
property which is - unless set explicitly - set to whateverVersionPrefix
orVersion
is set to. It does not read the attributes of the built assembly/ies.A workaround which works only using full-framework msbuild (
msbuild
command line or in vs) - as I posted on https://stackoverflow.com/questions/47818235/msbuild-tpack-nuget-package-has-allways-the-same-version/47819996#47819996 - is to add the following to the csproj file:for a multi-targeting project (https://stackoverflow.com/questions/48065516/build-project-with-multiple-targetframeworks-in-tfs-as-nuget-package/48069440#48069440):
I’m using Visual Studio 2017 (15.9.5). My .Net Standard 2.0 project is using an AssemblyInfo.cs file. When building the nuget package this information is ignored (as explained here, fine by me). What’s confusing is that after the project was compiled, the “Package” tab of the project settings in Visual Studio does show the information from the AssemblyInfo attributes (if necessary, close and reopen the project settings tab). Because of this, it looks like the package information are correctly set, when in fact they will not be applied because they originate from AssemblyInfo attributes.