Where to specify version number in ASP.NET Web Site

喜夏-厌秋 提交于 2019-12-21 12:22:41

问题


So I have an ASP.NET 'Web Site' (as opposed to a Web Application) which has no AssemblyInfo.cs file or Bin folder or anything like that.

I want to have a way to specify an Assembly version number (e.g. 7.0.2.0). In a Web Application you would do this in an AssemblyInfo.cs file.

I've tried adding a Properties folder with an AssemblyInfo.cs file but I don't think its being picked up - because when I call Assembly.GetExecutingAssembly().GetName().Version.ToString() I get 0.0.0.0

So: What do I have to do to get AssemblyInfo.cs working OR how can I specify a version number?


回答1:


K Scott Allen has a post here, but personally i'd recommend you move to a Web Application Project.




回答2:


The version number sets the version of the dll. As you don't precompile web site projects, I'm not sure you can set a version number like this. You may just need to version by using a label or something in your source control system and mange this yourself.




回答3:


There's no single assembly for you to set the version number of. You need to rethink what you're trying to accomplish.




回答4:


Try putting the AssemblyInfo class into the App_Code folder.




回答5:


Maybe I came a bit late, but I came across the problem, and what i did was just creating and assembly containing just an AssemblyInfo.cs source file with the attributes i wanted.

Then I added the project AssemblyInfo to my solution.

And then I implemented a script to be run on deployment as follows:

:: Just prepare and clean before starting
SET DOTNETINSTALLDIR=%FRAMEWORKDIR%\v4.0.30319
rmdir /S /Q "%Depot%\AssetExplorer.Web"
mkdir "%Depot%\AssetExplorer.Web"

:: Compiles the web site
call "%DOTNETINSTALLDIR%\aspnet_compiler" -f -c -u -p "%~1..\Discovery.Web" -v "/AssetExplorer" "%Depot%\AssetExplorer.Web"

:: Time to merge the contents into the assembly
call "%WindowsSDK_ExecutablePath_x86%\aspnet_merge" -o ICM.dll -a "%Depot%\AssetExplorer.Web" -copyattrs "%~1..\AssemblyInfo\obj\Release\AssemblyInfo.dll"

The magic is in

-copyattrs "%~1..\AssemblyInfo\obj\Release\AssemblyInfo.dll", 

it takes the attributes from AssemblyInfo.dll and copies them into the generated assembly.

Hope it helps ;)



来源:https://stackoverflow.com/questions/1521125/where-to-specify-version-number-in-asp-net-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!