开发者

Where to specify version number in ASP.NET Web Site

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?


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


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.


Try putting the AssemblyInfo class into the App_Code folder.


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


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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜