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?