Created
October 27, 2017 19:47
-
-
Save vardars/6e39bae812a8436885b1b4818591903d to your computer and use it in GitHub Desktop.
msbuild publish powershell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$solutionName = "$$$SOLUTION_NAME$$$" | |
$systemRoot = $env:systemroot | |
$msbuildExe = "$systemRoot\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" | |
$currentPath = Convert-Path(".") | |
$currentDate = Get-Date -format yyyyMMdd-HHmm | |
function ZipFiles( $zipfilename, $sourcedir ) | |
{ | |
Add-Type -Assembly System.IO.Compression.FileSystem | |
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal | |
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false) | |
} | |
&$msbuildExe ("$currentPath\..\$solutionName", "/verbosity:q", "/p:DeployOnBuild=true", "/p:PublishProfile=DefaultPublish") | |
Remove-Item "$currentPath\temp\" -include *.config -Force -Recurse | |
ZipFiles "publish-package-$currentDate.zip" "$currentPath\temp\" | |
Remove-Item "$currentPath\temp\" -Force -Recurse | |
if (!$?) { | |
echo "!!! ABORTING !!!";pause;exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change "$$$SOLUTION_NAME$$$" with .sln file name
change "DefaultPublish" with publish profile name
set "$currentPath..$solutionName" relative path from ps1 to sln path