title: nuget pack doesn't read assembly version from Visual Studio project
body: <p>I'm following along <a href="https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#new-file-with-default-values" rel="nofollow noreferrer">this official doc</a> about creating a nuget package with <code>nuget.exe</code>. I'm trying to create a nuspec file out of a Visual Studio project.</p>
  <p>According to the docs, when you run</p>
  <pre><code>&gt; nuget spec
  </code></pre>
  <p>From the directory where your <code>.csproj</code> file resides, it creates a tokenized <code>.nuspec</code> file. Then, when you run <code>nuget pack &lt;project-name&gt;.csproj</code> the values from the project file are used to replace the tokens in the nuspec file.</p>
  <p>So in my example, I have a project called <code>Logger1</code>. After running <code>nuget spec</code>, I have the following <code>.nuspec</code></p>
  <pre><code>&lt;package &gt;
    &lt;metadata&gt;
      &lt;id&gt;$id$&lt;/id&gt;
      &lt;version&gt;$version$&lt;/version&gt;
      &lt;title&gt;$title$&lt;/title&gt;
      &lt;authors&gt;Yoav Klein&lt;/authors&gt;
      &lt;requireLicenseAcceptance&gt;false&lt;/requireLicenseAcceptance&gt;
      &lt;license type=&quot;expression&quot;&gt;MIT&lt;/license&gt;
  ...
  </code></pre>
  <p>Now, <a href="https://To%20use%20these%20tokens,%20run%20nuget%20pack%20with%20the%20project%20file%20rather%20than%20just%20the%20.nuspec.%20For%20example,%20when%20using%20the%20following%20command,%20the%20$id$%20and%20$version$%20tokens%20in%20a%20.nuspec%20file%20are%20replaced%20with%20the%20project%27s%20AssemblyName%20and%20AssemblyVersion%20values:%20%20ps%20%20Copy%20nuget%20pack%20MyProject.csproj" rel="nofollow noreferrer">this doc</a> says that:</p>
  <blockquote>
  <p>To use these tokens, run nuget pack with the project file rather than just the .nuspec. For example, when using the following command, the $id$ and $version$ tokens in a .nuspec file are replaced with the project's AssemblyName and AssemblyVersion values:</p>
  </blockquote>
  <pre><code>nuget pack MyProject.csproj
  </code></pre>
  <p>My Assembly version is:</p>
  <pre><code># AssemblyInfo.cs
  
  // by using the '*' as shown below:
  // [assembly: AssemblyVersion(&quot;1.0.*&quot;)]
  [assembly: AssemblyVersion(&quot;1.6.0.0&quot;)]
  [assembly: AssemblyFileVersion(&quot;1.0.0.0&quot;)]
  </code></pre>
  <p>Now I run <code>nuget pack Logger1.csproj</code> and I expect the version of the package to be drawn from the <code>AssemblyVersion</code> of the project, as promised by the docs.</p>
  <p>After creating the package, I examine the .nuspec file in the package created:</p>
  <pre><code>&lt;package xmlns=&quot;http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd&quot;&gt;
    &lt;metadata&gt;
      &lt;id&gt;Logger1&lt;/id&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
  </code></pre>
  <p>As you can see, for some reason, it doesn't take the correct value of the <code>AssemblyVersion</code> which is <code>1.6.0</code>, but rather always uses the value <code>1.0.0</code>.</p>
  <p>Can someone tell me what am I doing wrong?</p>
  <p>NuGet Version: 5.8.1.7021</p>
  <hr />
  <p>Just to confirm, after building the dll, I can see that the assembly version is 1.6.0:</p>
  <pre><code>PS&gt; [Reflection.AssemblyName]::GetAssemblyName(&quot;$(pwd)\bin\Debug\Logger1.dll&quot;)
  
  Version        Name
  -------        ----
  1.6.0.0        Logger1
  </code></pre>