-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpublish.ps1
51 lines (37 loc) · 1.8 KB
/
publish.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
#### Configuration
$deleteExistingFiles = $false
$configuration = "Debug"
$publishsettings = ".\publishsettings.targets"
$sxaReferenceConfig = ".\zzz.Sxa.Reference.config"
$MSBuildCall = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBUILD.exe"
####
function Test-ConfigExists($configName){
if(Test-Path $configName){
$true
}else{
Write-Warning "Could not find config: '$($configName)"
Write-Warning "Make a copy of '$($currentDirectory)\$($configName).example' file. "
Write-Warning "Then remove '.example' from the file name and fill its content with your settings."
$false
}
}
if(-not (Test-ConfigExists $sxaReferenceConfig) -or -not(Test-ConfigExists $publishsettings)){
exit
}
[xml]$targets = Get-Content -Path $publishsettings
$publishUrl = $targets.Project.PropertyGroup.publishUrl
$siteName = (Split-Path $publishUrl -NoQualifier).TrimStart("\").TrimStart("/")
$sxa_site = Get-Website | ? { $_.Name -eq $siteName }
$publishPath = $sxa_site.physicalPath
$currentDirectory = Get-Item .
clear
Write-Host "1. Restoring Nuget packages" -ForegroundColor "Green"
.\nuget\nuget.exe restore .\XA.Reference.sln
Write-Host "2. Building projects" -ForegroundColor "Green"
Get-ChildItem $currentDirectory.FullName -Recurse -Filter "*.csproj"| %{
$projectPath = $_.FullName.Replace($currentDirectory.FullName,".")
Write-Host "`tBuilding project $($_.Name)" -ForegroundColor "Cyan"
& $MSBuildCall $projectPath /p:Configuration=$configuration /p:Platform=AnyCPU /t:WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=$deleteExistingFiles /p:publishUrl=$publishPath /v:q
}
Write-Host "3. Deploying '$sxaReferenceConfig'" -ForegroundColor "Green"
Copy-Item $sxaReferenceConfig "$($publishPath)\App_Config\Include"