-
Notifications
You must be signed in to change notification settings - Fork 0
/
Publish-Solution.ps1
49 lines (38 loc) · 1.37 KB
/
Publish-Solution.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
. .\Test-MsBuildInstalled.ps1
<#
.SYNOPSIS
Publishes a visual studio solution using a given publish profile.
.DESCRIPTION
Publishes a visual studio solution using a given publish profile. When the profile is not there, the project will be built but that published. This is due the behavior of msbuild
.PARAMETER SolutionPath
Path to the Visual Studio solutions file.
.PARAMETER ProfileName
Profile in the solution to be used.
.PARAMETER Configuration
Build configuration to be published. Defaults to "Debug".
.EXAMPLE
This publishes a solution file using a profile "ProfileName" and the build Configuration "Release"
Publish-Solution .\SolutionFile.sln ProfileName Release
#>
function Publish-Solution {
[CmdletBinding()]
param
(
[string]$SolutionPath,
[string]$ProfileName,
[string]$Configuration="Debug"
)
process
{
if(!(Test-Path($SolutionPath)))
{
throw "No file was found at $SolutionPath."
}
if(!(Test-MsBuildInstalled)) {
throw "MSBuild not found! Publish-Solution depends on MSBuild. Please install MSBuild."
}
Invoke-Expression "MSBuild $SolutionPath /p:DeployOnBuild=true /p:PublishProfile=$ProfileName"
}
}