Skip to content
Permalink
Browse files

Fixed deployment script to deploy to support Sitecore 9.2. Removed si…

…tecoreWebsiteFolder, this must be specified in the site json now.

Copied changes from commit fab740e.
  • Loading branch information...
michaellwest committed Jul 18, 2019
1 parent 8ad98a5 commit c14d328991d83d4bb0422c0fa674ea954e9c5852
@@ -58,14 +58,14 @@ function Filter-ProjectsForSite {
Param (
[Parameter(ValueFromPipeline=$True)]
[Object]$deployProject,
[int]$version,
[decimal]$version,
[string]$projectFilter
)

process {
# Include project only if version number matches or it is 0
if (($version -eq $deployProject.version) -or ($deployProject.version -eq 0) ) {

# Include project only if version is >= minVersion, and <= maxVersion (if a maxVersion is specified)
if ( ($version -ge $deployProject.minVersion) -and (!$deployProject.maxVersion -or ($version -le $deployProject.maxVersion)) ) {
# If a projectFilter is set, include it only if it matches
if (!$projectFilter -or $projectFilter -eq $deployProject.project ) {
$deployProject
@@ -3,7 +3,6 @@
#
Param([string]$projectfilter)

Write-Host "Project Filter: $($projectfilter)"
# Load dependents scripts
. "$PSScriptRoot\Deploy_Functions.ps1"

@@ -15,7 +14,9 @@ $userConfig = Get-Content "$PSScriptRoot\deploy.user.json" | ConvertFrom-Json
$sourceFolder = $PSScriptRoot

# Convert the variables into a hashtable for replacement
$variables = @{ "%%sourceFolder%%" = $sourceFolder }
$variables = @{
"%%sourceFolder%%" = $sourceFolder
}

Write-Host -ForegroundColor Cyan "*******************************************"
Write-Host -ForegroundColor Cyan " Sitecore PowerShell Extensions Deployment"
@@ -55,6 +56,11 @@ Get-ChildItem $deployUserConfigPath -Recurse -Include *.config | % {
Set-Content -Path $_ -Value $file
}

Write-Host
Write-Host -ForegroundColor Blue "User configuration build complete"
Write-Host -ForegroundColor Blue "Processing sites"
Write-Host


# Loop over the sites to deploy
foreach ( $site in $userConfig.sites )
@@ -64,46 +70,60 @@ foreach ( $site in $userConfig.sites )
# Get folders to deploy to from configuration and based on the destination site's version
$deployProjects = $deployConfig.deployProjects | Filter-ProjectsForSite -version $site.version -projectFilter $projectFilter

Write-Host
Write-Host -ForegroundColor Cyan "Deploying $(@($deployProjects).Count) projects to $($site.path)"
Write-Host

foreach ($deployProject in $deployProjects)
{
$deployFolder = Get-DeployFolder $sourceFolder $deployConfig $deployProject.project
$projectFolder = Get-ProjectFolder $sourceFolder $deployProject.project

if ($deployProjects)
{
Write-Host
Write-Host -ForegroundColor Green "Copying from $deployFolder to $($site.path)"
Write-Host -ForegroundColor Cyan "Deploying $(@($deployProjects).Count) projects to $($site.path)"
Write-Host

$siteWebsiteFolder = Join-Path $site.path $deployConfig.sitecoreWebsiteFolder

$filesToCopy = Get-ChildItem $deployFolder -Recurse | ? { $_.PSIsContainer -eq $False }
foreach ($deployProject in $deployProjects)
{
$deployFolder = Get-DeployFolder $sourceFolder $deployConfig $deployProject.project

if ($site.junction -and $deployProject.junctionPoints -ne $null) {
# Deploy any files that are not included in junction-folders
$filesToCopy = $filesToCopy | Filter-JunctionPoints $deployProject

# Create the junction points
$deployProject.junctionPoints | % {
$sourcePath = Join-Path $projectFolder $_
$sitePath = Join-Path $siteWebsiteFolder $_

Create-Junction $sitePath $sourcePath
if (!(Test-Path $deployFolder))
{
Write-Error "Cannot find deploy folder for project: $deployFolder"
continue
}

Write-Host "--- Created junction at $sitePath"
$projectFolder = Get-ProjectFolder $sourceFolder $deployProject.project

Write-Host
Write-Host -ForegroundColor Green "Copying from $deployFolder to $($site.path)"
Write-Host

$filesToCopy = Get-ChildItem $deployFolder -Recurse | ? { $_.PSIsContainer -eq $False }

if ($site.junction -and $deployProject.junctionPoints -ne $null) {
# Deploy any files that are not included in junction-folders
$filesToCopy = $filesToCopy | Filter-JunctionPoints $deployProject

# Create the junction points
$deployProject.junctionPoints | % {
$sourcePath = Join-Path $projectFolder $_
$sitePath = Join-Path $site.path $_

Create-Junction $sitePath $sourcePath

Write-Host "--- Created junction at $sitePath"
}
}
}

$filesToCopy | % {
$targetFile = $siteWebsiteFolder + $_.FullName.SubString($deployFolder.Length);

Copy-ItemWithStructure $_.FullName $targetFile
$filesToCopy | % {
$targetFile = Join-Path $site.path $_.FullName.SubString($deployFolder.Length);
Copy-ItemWithStructure $_.FullName $targetFile

Write-Host "--- Copied $targetFile"
Write-Host "--- Copied $targetFile"
}
}
}
else
{
Write-Host
Write-Host -ForegroundColor Cyan "No valid deployment sites for this project"
Write-Host
}

# Deploy UserConfiguration

@@ -112,7 +132,7 @@ foreach ( $site in $userConfig.sites )
Write-Host

Get-ChildItem $deployUserConfigPath -Recurse | ? { $_.Extension -eq ".config" } | % {
$targetFile = $siteWebsiteFolder + $_.FullName.SubString($deployUserConfigPath.Length);
$targetFile = Join-Path $site.path $_.FullName.SubString($deployUserConfigPath.Length);

Copy-ItemWithStructure $_.FullName $targetFile

@@ -72,16 +72,15 @@
<AssemblyFiles Include="$(TargetDir)Spe*.*">
<Visible>false</Visible>
</AssemblyFiles>
<SitecoreModuleFiles Include="$(ProjectDir)sitecore modules\**\*.*">
<ProjectDeployPathFiles Include="$(ProjectDeployPath)\**\*.*">
<Visible>false</Visible>
</SitecoreModuleFiles>
</ProjectDeployPathFiles>
</ItemGroup>
<PropertyGroup>
<ScriptLocation Condition=" '$(ScriptLocation)'=='' ">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\Post_Build.ps1'))</ScriptLocation>
</PropertyGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(AssemblyFiles)" DestinationFolder="$(ProjectDeployPath)\bin" ContinueOnError="true" />
<Copy SourceFiles="@(SitecoreModuleFiles)" DestinationFolder="$(ProjectDeployPath)\sitecore modules\%(RecursiveDir)" ContinueOnError="true" />
<Exec Command="PowerShell -NonInteractive -ExecutionPolicy Unrestricted -File &quot;$(ScriptLocation)&quot; -ProjectFilter &quot;$(MSBuildProjectName)&quot;" />
</Target>
</Project>
@@ -74,9 +74,6 @@
<AssemblyFiles Include="$(TargetDir)Spe*.*">
<Visible>false</Visible>
</AssemblyFiles>
<SitecoreModuleFiles Include="$(ProjectDir)sitecore modules\**\*.*">
<Visible>false</Visible>
</SitecoreModuleFiles>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spe.Abstractions\Spe.Abstractions.csproj">
@@ -65,9 +65,6 @@
<AssemblyFiles Include="$(TargetDir)Spe*.*">
<Visible>false</Visible>
</AssemblyFiles>
<SitecoreModuleFiles Include="$(ProjectDir)sitecore modules\**\*.*">
<Visible>false</Visible>
</SitecoreModuleFiles>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spe.Abstractions\Spe.Abstractions.csproj">
@@ -1,26 +1,25 @@
{
"deployFolder": "_Deploy",
"sitecoreWebsiteFolder" : "Website",
"userConfigurationFolder" : "UserConfiguration",
"deployProjects" : [
{
"project": "Spe.Abstractions",
"version": 0
"minVersion": 0
},
{
"project": "Spe",
"version": 0,
"minVersion": 0,
"junctionPoints": [
"sitecore modules\\PowerShell\\Assets",
"sitecore modules\\PowerShell\\Scripts",
"sitecore modules\\PowerShell\\Services",
"sitecore modules\\PowerShell\\Styles",
"sitecore modules\\PowerShell\\Styles",
"sitecore modules\\Shell\\PowerShell"
]
},
{
"project": "Spe.Package",
"version": 0
"minVersion": 0
}
],
"sitesDefault": {

0 comments on commit c14d328

Please sign in to comment.
You can’t perform that action at this time.