0

I am trying to make a .bat file to publish my application using ClickOnce via command line. I found this excellent post here on StackOverflow, which suggests creating a new <Target> in the .csproj file. The code from the post looks like this (I removed the clean part):

<PropertyGroup>
<ProjLocation>D:\Test\Projects\ClickOncePublish\ClickOncePublish</ProjLocation>
<ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
<ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
<DeploymentFolder>D:\Test\Publish\</DeploymentFolder>
</PropertyGroup>

<Target Name="Test" DependsOnTargets="Clean">

  <MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj" 
    Properties="$(DefaultBuildProperties)" 
    Targets="Publish"/>

  <ItemGroup>
    <SetupFiles Include="$(ProjPublishLocation)\*.*"/>
    <UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
  </ItemGroup>


    <Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\" />
    <Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"/>
</Target>

The issue I have here, is that I would like the file to work for others as well. And using a hardcoded <ProjLocation> makes this kind of tricky. Is there any way to make the path relative, or in other ways make it work on other PCs?

Jakob Busk Sørensen
  • 5,599
  • 7
  • 44
  • 96

1 Answers1

1

You can found all available msbuild constants here Common Macros for Build Commands and Properties

They are all in your deployment environment. Your ProjLocation constant looks like $(ProjectDir).

Anyway, if you need for step out your current directory, you can use a relative path like this:

$(ProjectDir)\..\..\Level2UpperSubFolder
Sergey Vaulin
  • 722
  • 4
  • 16