【问题标题】:Automatic Versions for Visual Studio on Web Page project网页项目中 Visual Studio 的自动版本
【发布时间】:2018-07-19 23:20:32
【问题描述】:

我在 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 中获得我最喜欢的扩展之一,以帮助我更新每个构建的版本。我已经设置好了,所以我有以下...

看起来不错,就像我在其他项目中设置的一样,并且我已经确认程序集的路径是 100% 正确的等等。

由于某种原因,当我构建或发布网页时,它永远不会更新版本。甚至自动版本日志也是空白的。有什么想法我可能做错了吗?

【问题讨论】:

    标签: asp.net vb.net visual-studio-2015 .net-assembly versioning


    【解决方案1】:

    乍一看,通往 AssemblyInfo 的路径似乎有些偏离。由于您在项目级别设置值,因此路径是相对于项目的,所以我认为您可以只说 .\App_Code\AssemblyInfo.vb。或者,我相信如果 AssemblyInfo.vb 项目位于“Properties”文件夹中,那么您甚至不必指定路径。

    【讨论】:

    • 我不认为将它放在一个名为 Properties 的新文件夹中是一种选择。如果文件不在App_Code 文件夹中,它将不会被编译。让我试试看新路径是否有效。
    • 是的,这可能取决于项目类型。另请注意,该文本框旁边有一个浏览按钮,可以很好地为您正确设置相对路径。如果它没有然后让我知道,那可能是一个需要解决的错误。
    • 解决方案似乎正在使用该路径!似乎当您使用右侧的大浏览 ... 按钮并选择程序集信息文件时,它会放置上面示例图像中显示的路径。但是,当我按照您的建议进行操作并手动将路径更改为.\App_Code\AssemblyInfo.vb(注意开头的句号)时,它就像一个魅力!谢谢!
    • 嗯,很高兴知道。我会得到一张票来更新浏览...按钮已修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-06
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 2011-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多