Skip to content

Instantly share code, notes, and snippets.

@igeta
Last active April 9, 2017 08:23
Show Gist options
  • Save igeta/7953387 to your computer and use it in GitHub Desktop.
Save igeta/7953387 to your computer and use it in GitHub Desktop.
@echo off
set sln=SampleApp
set proj=SampleApp
set conf=Release
set plat=x86
set publisher=Dummy Inc.
set product=Sample Application
set version=0.1.2.3
set projects=%userprofile%\Documents\Visual Studio 2013\Projects
set local=%projects%\%sln%\%proj%
set locbin=%local%\bin\%conf%
set verdir=%proj%_%version:.=_%
set apppub=%locbin%\app.publish
set pubbin=%apppub%\Application Files\%verdir%
set server=127.0.0.1
set providerurl=http://%server%/%proj%/%proj%.application
set appcodebase=Application Files\%verdir%\%proj%.exe.manifest
echo Start publishing ClickOnce application.
echo.
echo -- cleanup app publish directory
rmdir /s /q %pubbin%
echo -- publish ClickOnce application
msbuild "%local%\%proj%.csproj" /target:publish /property:Configuration=%conf%;Platform=%plat%;PublishDir="%apppub%\\"
echo -- remove .deploy extensions
pushd %pubbin%
rename *.deploy *.
for /r /d %%f in (*) do (rename "%%f\*.deploy" *.)
popd
echo -- copy .config files
copy "%locbin%\%proj%.exe.config" "%pubbin%\" /y
copy "%locbin%\%proj%.exe.config" "%pubbin%\App.Config" /y
echo -- update and re-sign application manifest (.exe.manifest)
mage ^
-Update "%pubbin%\%proj%.exe.manifest" ^
-FromDirectory "%pubbin%" ^
-ToFile "%pubbin%\%proj%.exe.manifest" ^
-Name %proj%
-Version %version% ^
-CertFile "%local%\%proj%_TemporaryKey.pfx"
echo -- update and re-sign deployment manifest (.application)
mage ^
-Update "%apppub%\%proj%.application" ^
-AppManifest "%pubbin%\%proj%.exe.manifest" ^
-ProviderUrl "%providerurl%" ^
-AppCodeBase "%appcodebase%" ^
-Name %proj%.application ^
-Version %version% ^
-Publisher "%publisher%" ^
-CertFile "%local%\%proj%_TemporaryKey.pfx"
echo -- add .deploy extensions
pushd %pubbin%
rename * *.*.deploy
for /r /d %%f in (*) do (rename "%%f\*" *.*.deploy)
rename *.manifest.deploy *.
popd
echo.
echo Publishing ClickOnce application is done.
echo.
echo %apppub%
echo.
echo You should update 'Product' name using MageUI.exe, if necessary.
echo The certificate file is '%local%\%proj%_TemporaryKey.pfx'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment