14
votes

I have an asp.net mvc application that I am publishing with Publish feature of Visual Studio and I have a custom MSBuild task that needs the directory that I am publishing to so it knows where to copy some custom build files to... I've tried $(OutDir), $(PublishDirectory) and a bunch of others... how do I get this path?

3

3 Answers

12
votes

For me what worked was:

$(PublishUrl)

And i got what i was needing: My publish directory.

Thanks.

4
votes

I was able to combine $(ProjectDir) & $(PublishDir) to get the publishing folder. However, I was publishing SharePoint app but I think it should work for other cases as well.

For example to call a program

<Exec Command="&quot;$(ProjectDir)\app.exe&quot; &quot;$(ProjectDir)$(PublishDir) &quot;"/>
1
votes

You should be able to use the PackageArchiveRootDir property to resolve that. The default value for that is obj\Debug\Package. So if you need the full path you just combine the MSBuildProjectDirectory with the PackageArchiveRootDir like: $(MSBuildProjectDirectory)\$(PackageArchiveRootDir).