-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBuild-WSPs.ps1
50 lines (47 loc) · 2.41 KB
/
Build-WSPs.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
50
cls
function Get-ScriptDirectory {
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
function Get-MSBuildPath {
# By default PowerShell does not have HKEY_CLASSES_ROOT defined so we have to define it
if ($(Get-PSDrive HKCR -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
}
if (Test-Path HKCR:\VisualStudio.DTE.12.0) {
#return "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"
} else {
#return "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
}
if ([System.IO.Directory]::Exists("C:\Program Files (x86)\MSBuild\12.0")) {
return "C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe"
} elseif ([System.IO.Directory]::Exists("C:\Program Files (x86)\MSBuild\14.0")) {
return "C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe"
}
}
Set-Location (Get-ScriptDirectory)
$solutionFolder = Resolve-Path "."
$msbuild = Get-MSBuildPath
$rootBuildFolder = Resolve-Path ".\Packages"
$outDir = "$rootBuildFolder"
mkdir $outDir -Force | Out-Null
$projects = @{
"$solutionFolder\Lapointe.SharePoint2010.PowerShell\Lapointe.SharePoint2010.PowerShell.csproj" = @("ReleaseMOSS", "ReleaseFoundation")
"$solutionFolder\Lapointe.SharePoint2013.PowerShell\Lapointe.SharePoint2013.PowerShell.csproj" = @("ReleaseMOSS", "ReleaseFoundation")
"$solutionFolder\Lapointe.SharePoint2013.PowerShell\Lapointe.SharePoint2016.PowerShell.csproj" = @("ReleaseMOSS")
}
foreach ($project in $projects.Keys) {
Write-Host "Building $project..." -ForegroundColor Green
foreach ($config in $projects[$project]) {
$version = "SP2010"
if ($project.Contains("Lapointe.SharePoint2013.PowerShell.csproj")) { $version = "SP2013" }
elseif ($project.Contains("Lapointe.SharePoint2016.PowerShell.csproj")) { $version = "SP2016" }
Write-Host "Building $config..." -ForegroundColor Green
del "$outDir\$version\$config\*.wsp" -Force -ErrorAction SilentlyContinue
&$msbuild $project /v:m /t:Rebuild /t:Package /p:Configuration="$config" /p:OutDir="$outDir\$version\$config"
del "$outDir\$version\$config\*.xml" -Force -ErrorAction SilentlyContinue
del "$outDir\$version\$config\*.dll" -Force -ErrorAction SilentlyContinue
del "$outDir\$version\$config\*.pdb" -Force -ErrorAction SilentlyContinue
del "$outDir\$version\$config\*.config" -Force -ErrorAction SilentlyContinue
}
}