Skip to content

Instantly share code, notes, and snippets.

@ximon

ximon/.cs_or_vbproj

Created May 30, 2019
Embed
What would you like to do?
Clickonce - update minimum version on publish
<!--
Install the NuGet package 'AutoUpdateProjectsMinimumRequiredClickOnceVersion'
remove the post build task and add the following to the .csproj / .vbproj
-->
<!-- #1 Place this line at the top of any msbuild script (ie, csproj, etc) -->
<PropertyGroup>
<PowerShell># 2>nul || type %~df0|find /v "setlocal"|find /v "errorlevel"|powershell.exe -noninteractive -executionpolicy Unrestricted -&amp; exit %errorlevel% || #</PowerShell>
</PropertyGroup>
<!-- #2 in any target you want to run a script -->
<Target Name="BeforePublish" >
<PropertyGroup> <!-- #3 prefix your powershell script with the $(PowerShell) variable, then code as normal! -->
<myscript>$(PowerShell)
cd $(ProjectDir)PostBuildScripts
.\AutoUpdateProjectsMinimumRequiredClickOnceVersion.ps1 -ProjectFilePaths "$(ProjectPath)"
</myscript>
</PropertyGroup>
<!-- #4 and execute the script like this -->
<Exec Command="$(myscript)" EchoOff="true" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment