Pregunta

Estoy intentando configurar un directorio virtual mediante msbuild y las tareas de la comunidad msbuild pero no puede encontrar la manera de cómo especificar una ruta relativa que está fuera del $(MSBuildStartupDirectory).

Mi proyecto está estructurado de la siguiente manera:

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

Lo que me gustaría hacer es algo como esto (nota que los puntos $(MSBuildStartupDirectory) a c:\proj\build):

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

Por desgracia esto no funciona -. El '..' no está resuelto y el directorio virtual y luego puntos a c:\proj\build\..\src\website

punto alguien me puede un indicio de cómo trabajar con las rutas (relativas) en msbuild?

¿Fue útil?

Solución

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top