Why do I need VirtualPath property for AspNetCompiler task

假装没事ソ 提交于 2019-12-10 12:44:08

问题


I'm trying to write a build system for a website so that I can do a one click build. I'm getting a clean copy of the code from the source code repository and then using msbuild to run a AspNetCompiler task to do all the precompile for the website.

The thing that is confusing me is that I need to specify a VirtualPath or MetabasePath. I don't have a metabase path - I want to just compile it into a local directory that can then be deployed to whatever servers are chosen (ie dev servers first then live servers later).

VirtualPath is tricky because I want the same code to be deployable into multiple locations - the code uses some context and configuration details to work out its SiteID to display different info - so specifying a single virtual path doesn't seem wise.

There are various other questions out there along a similar line (eg VirtualPath in AspNetCompiler MSBuild Task - does it have to be equal to the final deployed Virtual Path? ) but the only answers I've found seem to be more anecdotal - ie they jsut say it seems to make no difference in their experience.

However, I can't believe that it really makes no difference. There must be some situation in which this is used or else it wouldn't be there and wouldn't be required.

So does anybody know (and preferably have a reference) for what this does? What problems might be caused by passing a made up virtual path into the task?


回答1:


When publishing a site in Visual Studio, it is not required to enter this data (in fact, I have never even seen any option to). I'm surprised it is mandatory in an MS-Build configuration.

You might want to "reverse engineer" whatever Visual Studio uses but my guess is it will be a single slash "/" or something like that.

Having said that, the requirement might have something to do with the issues around precompiled websites using Virtual Path Providers or Resource Providers.




回答2:


Visual Studio uses a single backslash for the VirtualPath property. The full command line string that is generated looks something like this.

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v \ -p C:\src\Web\WebApplication1\obj\Release\AspnetCompileMerge\Source C:\src\Web\WebApplication1\obj\Release\AspnetCompileMerge\TempBuildDir 


来源:https://stackoverflow.com/questions/12348598/why-do-i-need-virtualpath-property-for-aspnetcompiler-task

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