Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get publish directory in MSBuild

Tags:

msbuild

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?

like image 904
Shane Avatar asked Mar 08 '10 19:03

Shane


People also ask

How do I publish with MSBuild?

You can pass /p:PublishUrl="newpath" to the msbuild command. You would also see this set in the csproj file which you can change.

How do I change the publish path in Visual Studio?

To specify a publishing location With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. In ClickOnce for . NET Core 3.1 and .

How do I publish a Visual Studio project locally?

Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish. Visual Studio writes the files that comprise your application to the local file system. The Publish tab now shows a single profile, FolderProfile.


3 Answers

For me what worked was:

$(PublishUrl)

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

Thanks.

like image 153
netrevisanto Avatar answered Oct 15 '22 23:10

netrevisanto


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;"/>
like image 31
TT77 Avatar answered Oct 16 '22 00:10

TT77


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).

like image 1
Sayed Ibrahim Hashimi Avatar answered Oct 16 '22 00:10

Sayed Ibrahim Hashimi