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?
You can pass /p:PublishUrl="newpath" to the msbuild command. You would also see this set in the csproj file which you can change.
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 .
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.
For me what worked was:
$(PublishUrl)
And i got what i was needing: My publish directory.
Thanks.
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=""$(ProjectDir)\app.exe" "$(ProjectDir)$(PublishDir) ""/>
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With