I have an ASP.NET project that contains a Web Deployment project (to compile the website) and a Setup project (that creates the Setup and install the compiled version of the website).
我有一个ASP.NET项目,其中包含一个Web部署项目(用于编译网站)和一个安装项目(创建安装程序并安装网站的编译版本)。
I always change the application version on the Setup Project and I want to be able to reference that version number into the Website itself but without creating an entry in the web.config with the version number (not today, but I think that in the future I will forgot to change the version number in the web.config)
我总是在安装项目上更改应用程序版本,我希望能够将该版本号引用到网站本身但不在web.config中创建带有版本号的条目(不是今天,但我认为将来我将忘记更改web.config中的版本号
Is there any trick that I can use to get this behaviour?
有什么技巧可以用来获得这种行为吗?
Just like using the App.Config in WinForms using just:
就像在WinForms中使用App.Config一样:
Version vrs = new Version(Application.ProductVersion);
myVersionLabel.Text = "Major: " + vrs.Major + " Minor: " + vrs.Minor;
1 个解决方案
#1
You can always do a custom action that writes/updated the setup version to your web.config. No worries about forgetting to do that manually. EDIT: I made a blog post about how to do this. Take a look here.
您始终可以执行自定义操作,将安装程序版本写入/更新到web.config。不用担心忘记手动执行此操作。编辑:我发了一篇关于如何做到这一点的博客文章。看看这里。
#1
You can always do a custom action that writes/updated the setup version to your web.config. No worries about forgetting to do that manually. EDIT: I made a blog post about how to do this. Take a look here.
您始终可以执行自定义操作,将安装程序版本写入/更新到web.config。不用担心忘记手动执行此操作。编辑:我发了一篇关于如何做到这一点的博客文章。看看这里。