-
Notifications
You must be signed in to change notification settings - Fork 10
/
default.ps1
71 lines (54 loc) · 2.91 KB
/
default.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
properties {
$projectDir = Resolve-Path .
$slnFile = "$projectDir\Campmon.Dynamics.sln"
$webResourceProject = 'Campmon.Dynamics.WebResources'
$pluginProject = 'Campmon.Dynamics.Plugins'
$workflowProject = 'Campmon.Dynamics.WorkflowActivities'
$connectionStrings = @{
"dev" = "Url=https://campmondev0.crm.dynamics.com/;[email protected];Password=pass@word1;AuthType=Office365";
"test" = "Url=https://campmontest1.crm.dynamics.com/;[email protected];Password=pass@word1;AuthType=Office365"
}
$solutionName = 'CampaignMonitor'
$solutionVersionNumber = $versionNumber
$outputDir = $outputPath
}
task RestoreNuGet {
&"$projectDir\.nuget\nuget.exe" restore "$slnFile"
}
task Compile -depends RestoreNuGet {
$params = '/target:Rebuild /property:Configuration=Release /verbosity:minimal'
$buildResult = Invoke-MsBuild $slnFile -MsBuildParameters $params -ShowBuildOutputInCurrentWindow
"Compile succeeded: $($buildResult.buildSucceeded)"
}
task UpdateVersion -precondition { $solutionVersionNumber } {
$org = Get-Crmconnection -ConnectionString $connectionStrings.dev
if ($org.IsReady) { "Connected successfully" } else { throw "Unable to connect" }
$results = Get-CrmRecords -conn $org -EntityLogicalName solution -FilterAttribute uniquename -FilterOperator like -FilterValue $solutionName -Fields version
if ($results.CrmRecords.Count -ne 1) {
throw "Could not find solution with name $solutionName."
}
$updatedSolution = $results.CrmRecords[0]
$updatedSolution.version = $solutionVersionNumber
Set-CrmRecord -conn $org -CrmRecord $updatedSolution
"Updated solution to version $solutionVersionNumber"
}
task ExportSolutions -depends Compile,UpdateVersion {
$org = Get-Crmconnection -ConnectionString $connectionStrings.dev
if ($org.IsReady) { "Connected successfully" } else { throw "Unable to connect" }
if (-not (Test-Path $outputDir)) {
New-Item $outputDir -type Directory > $null
}
Publish-CrmAllCustomization -conn $org
$unmanagedFileName = "$solutionName-Unmanaged-$solutionVersionNumber.zip"
Export-CrmSolution -conn $org -SolutionName $solutionName -SolutionFilePath $outputDir -SolutionZipFileName $unmanagedFileName -TargetVersion 8.0
$managedFileName = "$solutionName-Managed-$solutionVersionNumber.zip"
Export-CrmSolution -conn $org -SolutionName $solutionName -SolutionFilePath $outputDir -SolutionZipFileName $managedFileName -TargetVersion 8.0 -Managed
}
task DeployToTest {
$org = Get-CrmConnection -ConnectionString $connectionStrings.test
$managedFileName = "$solutionName-Managed-$solutionVersionNumber.zip"
$filePath = Join-Path $outputDir $managedFileName
Import-CrmSolution -conn $org -SolutionFilePath $filePath -ActivatePlugins
}
task Default -depends Compile
task Create -depends ExportSolutions, DeployToTest