-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
75 lines (62 loc) · 2.42 KB
/
azure-pipelines.yml
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
72
73
74
75
pool:
vmImage: 'windows-2019'
name: $(SourceBranchName)+1.$(Date:yyyy.MM)$(Rev:.r)
variables:
disable.coverage.autogenerate: 'true'
steps:
- script: echo Starting build pipeline!
displayName: 'Hello from Albanian Xrm'
- powershell: |
echo "##vso[task.setvariable variable=configuration;isOutput=true]$(IF($env:BRANCH -eq "refs/heads/main"){"Azure Pipelines"}else{"release"})"
echo "##vso[task.setvariable variable=BuildNumber;isOutput=true]$(($env:BuildNumber).Substring(($env:BuildNumber).LastIndexOf('+')+1))"
name: MyVars
env:
BRANCH: $(Build.SourceBranch)
BuildNumber: $(Build.BuildNumber)
displayName: 'Set Configuration Variable'
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: DownloadSecureFile@1
name: SignKey
inputs:
secureFile: 'AlbanianXrm.BackgroundWorker.snk'
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Secret'
- powershell: echo "##vso[task.setvariable variable=Path;isOutput=true]$((get-item $env:SECURE_FILE).Directory.FullName)"
name: secretFolder
env:
Secure_File: $(SignKey.secureFilePath)
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Secret folder'
- task: CopyFiles@2
inputs:
sourceFolder: $(secretFolder.Path)
contents: 'AlbanianXrm.BackgroundWorker.snk'
targetFolder: 'AlbanianXrm.BackgroundWorker'
overWrite: true
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Overwrite AlbanianXrm.BackgroundWorker SignKey'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
configuration: $(MyVars.configuration)
msbuildArguments: '/p:Version=$(MyVars.BuildNumber)'
displayName: 'Building Solution'
- task: NuGetCommand@2
displayName: 'Creating NuGet package'
inputs:
command: 'pack'
packagesToPack: '**/*.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)/NuGet'
buildProperties: version=$(MyVars.BuildNumber);configuration=Release
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: PublishBuildArtifacts@1
displayName: 'Publishing NuGet package to pipeline'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/NuGet'
artifactName: 'NuGet Package'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))