代码之家  ›  专栏  ›  技术社区  ›  Arvo Bowen

网页项目上Visual Studio的自动版本

  •  0
  • Arvo Bowen  · 技术社区  · 6 年前

    我在Visual Studio 2015中有一个旧的“网页”项目,正在尝试将版本添加到其中。我在app_code文件夹下创建了assemblyinfo.vb文件,其中包含以下内容…

    Imports System
    Imports System.Reflection
    Imports System.Runtime.InteropServices
    
    ' General Information about an assembly is controlled through the following 
    ' set of attributes. Change these attribute values to modify the information
    ' associated with an assembly.
    
    ' Review the values of the assembly attributes
    
    <Assembly: AssemblyTitle("MyWebSite")>
    <Assembly: AssemblyDescription("")>
    <Assembly: AssemblyCompany("")>
    <Assembly: AssemblyProduct("MyWebSite")>
    <Assembly: AssemblyCopyright("Copyright © MyCompany 2018")>
    <Assembly: AssemblyTrademark("")>
    
    <Assembly: ComVisible(False)>
    
    ' Version information for an assembly consists of the following four values:
    '
    '      Major Version
    '      Minor Version 
    '      Build Number
    '      Revision
    '
    ' You can specify all the values or you can default the Build and Revision Numbers 
    ' by using the '*' as shown below:
    ' <Assembly: AssemblyVersion("1.0.*")> 
    
    <Assembly: AssemblyVersion("1.2.3.4")>
    <Assembly: AssemblyFileVersion("1.2.3.4")>
    

    在我的网站上我有一个template.master,它引用了…

    <asp:Literal runat="server" ID="Version"></asp:Literal>
    

    在我的网站上,我还有一个template.master.vb,其中包含…

    Dim assembly As Assembly = Assembly.Load("App_Code")
    Dim ver As Version = assembly.GetName().Version
    Version.Text = "Version: " + ver.Major.ToString() + "." + ver.Minor.ToString() + "." + ver.Revision.ToString() + " build (" + ver.Build.ToString() + ")"
    

    现在,当我构建我的站点时,它看起来和我预期的完全一样,如下所示…

    版本:1.2.4版本(3)

    现在我已经有了所有的设置,我希望在Visual Studio中得到一个我最喜欢的扩展来帮助我更新每个构建的版本。我已经设置好了,所以我有以下内容… enter image description here

    它看起来很好,就像我在其他项目中设置的一样,我已经确认了到组件的路径是100%正确的等等。

    出于某种原因,当我构建或发布网页时,它将永远不会更新版本。甚至自动版本日志也是空白的。你知道我做错了什么吗? enter image description here

    1 回复  |  直到 6 年前
        1
  •  1
  •   Michael Adamission    6 年前

    乍一看,路径似乎稍微偏离了assemblyinfo。由于您是在项目级别设置值,因此路径是相对于项目的,所以我认为您可以这样说。\app\code\assemblyinfo.vb。另外,我相信如果assemblyinfo.vb项目在“properties”文件夹中,那么您甚至不必指定路径。