简体   繁体   中英

Where does the “Go To Definition” version number come from?

In Visual Studio 2019, if you right click on a symbol, you can select "Go To Definition". If the symbol is not defined in your code, it will attempt to generate the code from the dll.

When it generates this file, it puts a #region comment at the top of it. This is an example of what my region comment looks like:

#region Assembly Logging.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null
// C:\Users\myUserId\.nuget\packages\logging.client\7.0.0.43\lib\netstandard2.0\Logging.Client.dll
#endregion

The key part is that it says Version=6.0.1.0 . I opened up the NuGet file, and, on the properties of Logging.Client.dll, the version says 7.0.0.43:

Logging.Client.dll 的属性

So, my question is: Where does the version number shown on the line of the #region comment get pulled from?

NOTE: I looked at this similar question, but the steps of deleting the existing packages, restarting Visual Studio and rebuilding did not resolve my issue: Latest version of nuget package still not up to date

Where does the “Go To Definition” version number come from?

It is from AssemblyVerion attribute on VS and it is set in your nuget project by the nuget author.

Please see the below interpretation.

===================================================================

I assume that logging.client nuget package is your own nuget package.(created by yourself)

This is a normal behavior of the nuget and assembly mechanism. It is not an issue and it is just defined that way by the author of the package.

These make sense and are defined by the author when the nuget package is created and can be modified by the author. It's just that they have different functions from each other to deal with the mechanism of nuget.

The Version=6.0.1.0 is the assembly version of the dll which used by framework. It is a built-in version number which is used during build or used at runtime. It can only be accessed by vs internally. To be precise , this is its real version number.

And File Version 7.0.0.43 is the version of the dll, which is used for external display and can be accessed externally.

And Product Version 7.0.0.43 means the nuget package version which also can access outside VS.

So, they all are defined by the author as he want.

See this official document about the function of these attributes: Use AssemblyVersion and AssemblyFileVersion attributes .

They all have professional terms in VS:

AssemblyVersion means 6.0.1.0 , AssemblyFileVersion means File Version 7.0.0.43 and NugetVersion means Product Version 7.0.0.43 . And they can be also access outside VS.

====================================================

In my side , I created a net standarad class library project called ClassLibrary1 .

Right-click on your net standard class library project, right-click on your project Properties --> Package

包属性对话框包括包版本、程序集版本和程序集文件版本。

1)

The Assembly version is used under Logging.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null .

When you install that package on the main project, on the main project, click on the dll on the References and you will see the internal version 6.0.1.0 under the Properties Window.

And when you install this package on a net framework project with packages.config , it will shows on the csproj file:

<ItemGroup>
    <Reference Include="ClassLibrary1, Version=6.0.1.0, Culture=neutral, processorArchitecture=MSIL">
        <HintPath>..\packages\ClassLibrary1.7.0.0.43\lib\netstandard2.0\ClassLibrary1.dll</HintPath>
    </Reference>

The version is used by the internal framework and at build or runtime and only be seen in VS.

2)

The Assembly File version is the file name, it shows on the dll's properties and shows outside VS as File Version which you described on the case.

3)

The Package Version is the version of the nuget package rather than the assembly dll version. They're different concepts.

In your side , it shows like this:

<ItemGroup>
    <Reference Include="ClassLibrary1, Version=6.0.1.0, Culture=neutral, processorArchitecture=MSIL">
        <HintPath>..\packages\ClassLibrary1.7.0.0.43\lib\netstandard2.0\ClassLibrary1.dll</HintPath>
    </Reference>

And in the dll's properties, it shows as Product Version .

Overall ,it is not an issue and each of them has a meaningful and specific function. If you want to change this, you should change your nuget project's Properties --> Package as I said above, modify them as the same. Then, repack its as nuget package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM