1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+
4+ # Build, sign, package and deploy .NET package for Microsoft.Agents.M365Copilot
5+
6+ name : $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
7+
8+ trigger :
9+ branches :
10+ include :
11+ - main
12+ paths :
13+ include :
14+ - ' dotnet/src/Microsoft.Agents.M365Copilot/Generated/**'
15+ - ' dotnet/src/Microsoft.Agents.M365Copilot/**/*.cs'
16+ - ' dotnet/src/Microsoft.Agents.M365Copilot/Microsoft.Agents.M365Copilot.csproj'
17+ tags :
18+ include : # ex Microsoft.Agents.M365Copilot-v0.1.0-preview.0, must use the hyphen t distinguish from Beta
19+ - ' Microsoft.Agents.M365Copilot-*'
20+
21+ pr : none
22+
23+ variables :
24+ buildConfiguration : ' Release'
25+ buildPlatform : ' Any CPU'
26+ nugetArtifacts : ' $(Build.ArtifactStagingDirectory)/Nugets'
27+
28+ resources :
29+ repositories :
30+ - repository : 1ESPipelineTemplates
31+ type : git
32+ name : 1ESPipelineTemplates/1ESPipelineTemplates
33+ ref : refs/tags/release
34+
35+ extends :
36+ template : v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
37+ parameters :
38+ pool :
39+ name : Azure-Pipelines-1ESPT-ExDShared
40+ vmImage : windows-latest
41+ stages :
42+ - stage : build
43+ displayName : ' Build and Sign .NET Package'
44+ # This condition allows the build to run for both tagged builds and manual builds.
45+ condition : or(contains(variables['Build.SourceBranch'], 'Microsoft.Agents.M365Copilot-'), eq(variables['Build.Reason'], 'Manual'))
46+ jobs :
47+ - job : build_and_sign
48+ displayName : ' Build, Test, and Sign V1'
49+ pool :
50+ name : Azure-Pipelines-1ESPT-ExDShared
51+ vmImage : windows-latest
52+ steps :
53+ - task : UseDotNet@2
54+ displayName : ' Use .NET 8'
55+ inputs :
56+ version : 8.x
57+ - task : UseDotNet@2
58+ displayName : ' Use .NET 6 (for code signing tasks)'
59+ inputs :
60+ packageType : sdk
61+ version : 6.x
62+ - task : NuGetToolInstaller@1
63+ displayName : ' Install Nuget dependency manager'
64+ inputs :
65+ versionSpec : ' >=6.0.0'
66+ checkLatest : true
67+
68+ # Enable signing for the .NET projects
69+ - pwsh : |
70+ # This allows us to not have to checkin .csproj or Directory.Build.props files with DelaySign and
71+ # SignAssembly set to to true. If the flag is set, then project is not debuggable with SignAssembly set
72+ # to true.
73+ $buildPropsPath = "$(Build.SourcesDirectory)/dotnet/Directory.Build.props"
74+ if (Test-Path $buildPropsPath) {
75+ $doc = New-Object System.Xml.XmlDocument
76+ $doc.Load($buildPropsPath)
77+ # Set the DelaySign element to 'true' so that delay signing is set.
78+ $delaySign = $doc.SelectSingleNode("//DelaySign");
79+ $delaySign.'#text'= "true"
80+ # Set the SignAssembly element to 'true' so that we can sign the assemblies.
81+ $signAssembly = $doc.SelectSingleNode("//SignAssembly");
82+ $signAssembly.'#text'= "true"
83+ $doc.Save($buildPropsPath);
84+ Write-Host "Updated the Directory.Build.props file so that we can sign the built assemblies."
85+ } else {
86+ Write-Host ""##vso[task.complete result=Failed;]Directory.Build.props file not found."
87+ }
88+
89+ displayName: 'Set project build properties ready to sign'
90+
91+ # Build v1
92+ - task : DotNetCoreCLI@2
93+ displayName : ' Build Microsoft.Agents.M365Copilot'
94+ # This condition allows the build to run for both tag builds and manual builds.
95+ condition : or(contains(variables['Build.SourceBranch'], 'Microsoft.Agents.M365Copilot-'), eq(variables['Build.Reason'], 'Manual'))
96+ inputs :
97+ projects : ' $(Build.SourcesDirectory)/dotnet/src/Microsoft.Agents.M365Copilot/Microsoft.Agents.M365Copilot.csproj'
98+ arguments : ' --configuration $(buildConfiguration) --no-incremental'
99+
100+
101+ # Strong name for v1 using ESRP
102+ - template : .azure-pipelines/templates/esrp-strongname.yml@self
103+ parameters :
104+ projectName : Microsoft.Agents.M365Copilot
105+ buildConfiguration : $(buildConfiguration)
106+
107+ # Code signing for v1 using ESRP
108+ - template : .azure-pipelines/templates/esrp-codesign-dll.yml@self
109+ parameters :
110+ projectName : Microsoft.Agents.M365Copilot
111+ buildConfiguration : $(buildConfiguration)
112+
113+ # Pack v1
114+ - pwsh : dotnet pack $(Build.SourcesDirectory)/dotnet/src/Microsoft.Agents.M365Copilot/Microsoft.Agents.M365Copilot.csproj /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output $(nugetArtifacts) --configuration $(buildConfiguration)
115+ # This condition allows the pack command to run for both tag builds and manual builds.
116+ condition : or(contains(variables['Build.SourceBranch'], 'Microsoft.Agents.M365Copilot-'), eq(variables['Build.Reason'], 'Manual'))
117+ displayName : ' Dotnet pack v1'
118+
119+ # Sign v1 NuGet package using ESRP
120+ - template : .azure-pipelines/templates/esrp-codesign-nuget.yml@self
121+ parameters :
122+ projectName : Microsoft.Agents.M365Copilot
123+ artifactStagingDirectory : $(nugetArtifacts)
124+
125+ templateContext :
126+ outputs :
127+ - output : pipelineArtifact
128+ displayName : ' Stage Microsoft.Agents.M365Copilot package artifacts'
129+ artifactName : Nugets
130+ targetPath : $(nugetArtifacts)
131+
132+ - stage : deploy
133+ displayName : ' Deploy v1 NuGet Package'
134+ dependsOn : build
135+ condition : or(and(contains(variables['Build.SourceBranch'], 'Microsoft.Agents.M365Copilot-'), succeeded()), eq(variables['Build.Reason'], 'Manual'))
136+ jobs :
137+ - deployment : publish_nuget_package
138+ displayName : ' Publish v1 NuGet Package'
139+ environment : agents-m365copilot-prod
140+ pool :
141+ name : Azure-Pipelines-1ESPT-ExDShared
142+ vmImage : windows-latest
143+ os : windows
144+ templateContext :
145+ type : releaseJob
146+ isProduction : true
147+ inputs :
148+ - input : pipelineArtifact
149+ artifactName : Nugets
150+ targetPath : $(nugetArtifacts)
151+ strategy :
152+ runOnce :
153+ deploy :
154+ steps :
155+ - task : 1ES.PublishNuget@1
156+ displayName : ' Publish v1 NuGet package via NuGet API Key'
157+ inputs :
158+ useDotNetTask : false
159+ packageParentPath : $(nugetArtifacts)
160+ packagesToPush : ' !$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg;$(nugetArtifacts)/**/*nupkg'
161+ nuGetFeedType : external # Change to external for external
162+ publishPackageMetadata : true
163+ publishFeedCredentials : ' M365 Copilot NuGet Connection'
0 commit comments