문제

I'm trying to setup a virtual directory using msbuild and the msbuild community tasks but cannot find a way how to specify a relative path which is outside the $(MSBuildStartupDirectory).

My project is structured like this:

c:\proj\
  src\
    website        (this is where the virtual dir should point to)
  build\
    build.proj     (this is the msbuild file)

What I'd like to do is something like this (note that $(MSBuildStartupDirectory) points to c:\proj\build):

<WebDirectoryCreate
  VirtualDirectoryName="website"
  VirtualDirectoryPhysicalPath="$(MSBuildStartupDirectory)\..\src\website" />

Unfortunately this doesn't work - the '..' is not resolved and and the virtual dir then points to c:\proj\build\..\src\website.

Can anyone point me a hint how to work with (relative) paths in msbuild?

도움이 되었습니까?

해결책

I tried that and it worked fine for me. I tested this on Windows XP using msbuild 4.0 and community tasks version 1.3.0.504.

I usually use MSBuildProjectDirectory since MSBuildStartupDirectory could be pointing elsewhere depending on how msbuild got executed.

The example below will create the web site and remove the .. entries from the path by using the FullPath metadata.

<ItemGroup>
    <WebPath Include="$(MSBuildProjectDirectory)\..\src\website" />
</ItemGroup>
<Target Name="CreateWeb">
    <Message Text="WebPath=@(WebPath)" Importance="high" />
    <Message Text="FullPath=%(WebPath.FullPath)" Importance="high" />
    <WebDirectoryCreate
        VirtualDirectoryName="website"
        VirtualDirectoryPhysicalPath="%(WebPath.FullPath)" />
</Target>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top