本文介绍了版本的ASP.NET Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我甚至不知道,如果是版本为它正确的字,但它必须做。我想开始由我们的用户请求把我们的内部应用一个版本x.x.xx'注意,让他们有一个粗略的,当它被更新的想法(和未来,使该显示变化的链接)。这似乎是使用AssemblyInfo.cs文件是一个好主意 -​​ 它可以让你自动更新生成+版本这是很好的(用于Web应用程序的.DLL)

I'm not even sure if versioning is the right word for it, but it'll have to do. I want to start putting a 'Version x.x.xx' note on our internal apps by request of our users, so they have a rough of idea of when it gets updated (and in the future, make that a link that shows changes). It seems like using the AssemblyInfo.cs file is a good idea - it lets you automatically update the build+revision which is nice (for the .DLL of the web application).

这是一个体面的方法吗?然后,每当我达到我的应用程序主要/次要版本的里程碑。我可以更新这些手工,是否正确?所有这一切都假定我其实可以从我的应用程序的版本信息。不知怎么的,我还没有线索如何做到无论是。

Is this a decent approach? Then whenever I reach the major/minor version milestones for my app. I can just update those manually, correct? All of this assumes I can actually get the version information from my app. somehow, which I haven't a clue how to do either.

推荐答案

我们做同样的事情在我们的应用程序。虽然你可以手动添加的版本号,我们的版本信息被添加到装配为我们的自动化构建过程的一部分(我们使用自定义的TFS 2008服务),我强烈建议。下面是我们使用控制(我们只是把这个在母版页底部):

We do the same thing in our application. Although you can add the version number manually, our version info is added to the assembly as part of our automated build process (we use a customized TFS 2008 service), which I highly recommend. Here's the control we use (we just put this at the bottom of the master page):

public class BuildVersion : WebControl
{
    /// <summary>
    /// Render override
    /// </summary>
    /// <param name="writer"></param>
    protected override void Render(HtmlTextWriter writer)
    {
        writer.Write("<!--");
        writer.Write("Version: ");
        writer.Write(GetAssemblyVersion());
        writer.Write("-->");
    }

    private string GetAssemblyVersion()
    {
        try
        {
            Object[] atts = Assembly.GetAssembly(this.GetType()).GetCustomAttributes(true);
            foreach (Object o in atts)
            {
                if (o.GetType() == typeof(AssemblyVersionAttribute))
                {
                    return ((AssemblyVersionAttribute)o).Version;
                }
            }
            return String.Empty;
        }
        catch
        {
            return "Failed to load assembly";
        }
    }
}

这篇关于版本的ASP.NET Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:08