Why do I need VirtualPath property for AspNetCompiler task
Asked Answered
P

2

10

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?

Predictor answered 10/9, 2012 at 9:15 Comment(0)
T
2

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.

Tiler answered 1/10, 2012 at 0:26 Comment(4)
Yeah, I'm quite surprised too. And I'm not sure how to go about reverse engineering what visual studio does. Without knowing what the property is used for its hard to search for what Visual Studio is using. Any suggestion on how I might do that would be appreciated.Predictor
In Visual Studio, go to Tools -> Options -> Projects And Solutions (Check the box "Show All Settings" if you cannot find it) -> "Build and run". Then set the output verbosity to Diagnostic. Open the output window (Ctrl-Alt-O) and perform a build. I don't have a website on this machine or I'd have had a quick look.Tiler
That is a brilliant option and may help debug some other issues I've been having. Sadly when it comes to the precompile step it seems to not have any full diagnostic output and just says the usual Building directory '/MSReporting/App_Code/'. type stuff without any extra debug output (such as parameters being used). :(Predictor
You could try using Process monitor, set a filter (Process name contains "devenv.exe" for example), and look what it is calling during a build. Visual Studio might not even be using MsBuild. It may be calling the c# compiler (csc.exe) directly which would complicate things allot I'm afraid. It's a pity I don't have the time to dig into this right now, but there is a fair chance I'll be running into it myself sooner or later when setting up build automation for one of our legacy apps.Tiler
U
1

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 
Unpleasantness answered 7/6, 2016 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.