Skip to content

Commit b836658

Browse files
Fix publishing problems (#5538)
* Removed our dependency to BuildTools by using the NugetCommand Azure Task. * We should publish a nuget named "SampleUtils", but we were publishing it with the name "SamplesUtils" * The naming conventions of our published nugets didn't match the ones described on arcade's docs: Versioning.md. I've also added the option so that when queuing the publishing build, we can pass the VERSIONKIND variable with value "release", so that it produces the nugets with arcade's conventions for "Release official build" nugets (as opposed to the "Daily official build" naming convention that's going to be used now by our CI that publishes nightly nugets).
1 parent 9a5f235 commit b836658

File tree

3 files changed

+21
-43
lines changed

3 files changed

+21
-43
lines changed

build/publish.proj

-37
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
11
<Project>
2-
3-
<ItemGroup>
4-
<PackageReference Include="Microsoft.DotNet.BuildTools" Version="$(BuildToolsPackageVersion)" />
5-
</ItemGroup>
62

73
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
84

9-
<UsingTask TaskName="ExecWithRetriesForNuGetPush" AssemblyFile="$(NuGetPackageRoot)\microsoft.dotnet.buildtools\$(BuildToolsPackageVersion)\lib\Microsoft.DotNet.Build.Tasks.dll" />
10-
115
<PropertyGroup>
126
<PublishSymbolsPackage>Microsoft.SymbolUploader.Build.Task</PublishSymbolsPackage>
137
<EnablePublishSymbols Condition="'$(EnablePublishSymbols)'==''" >true</EnablePublishSymbols>
148
<NuGetPushTimeoutSeconds Condition="'$(NuGetPushTimeoutSeconds)' == ''">600</NuGetPushTimeoutSeconds>
159
</PropertyGroup>
1610

1711
<Import Project="$(NuGetPackageRoot)\$(PublishSymbolsPackage.ToLower())\$(MicrosoftSymbolUploaderBuildTaskVersion)\build\PublishSymbols.targets" />
18-
19-
<Target Name="PublishPackages">
20-
<Error Condition="'$(NuGetFeedUrl)' == ''" Text="Missing required property NuGetFeedUrl" />
21-
<Error Condition="'$(NuGetApiKey)' == ''" Text="Missing required property NuGetApiKey" />
22-
23-
<ItemGroup>
24-
<NuGetPackages Include="$(ArtifactsDir)packages\**\*.nupkg"
25-
Exclude="$(ArtifactsDir)packages\**\*.snupkg" />
26-
27-
<!--
28-
IgnorableErrorMessages applies to the "ExectWithRetriesForNuGetPush" task.
29-
There's a very special failure scenario that we want to ignore. That scenario is
30-
when NuGet hits a timeout on one "push" attempt, and then gets a "Forbidden" response
31-
because the package "already exists" on the next response. This indicates that the
32-
timeout occurred, but the push was actually successful.
33-
-->
34-
<IgnorableErrorMessages Include="Overwriting existing packages is forbidden according to the package retention settings for this feed.">
35-
<ConditionalErrorMessage>Pushing took too long</ConditionalErrorMessage>
36-
</IgnorableErrorMessages>
37-
</ItemGroup>
38-
39-
<Message Text="Pushing ML.NET packages to $(NuGetFeedUrl)" />
40-
41-
<PropertyGroup>
42-
<DotnetToolCommand>$(MSBuildThisFileDirectory)..\.dotnet\dotnet</DotnetToolCommand>
43-
<NuGetPushCommand>$(DotnetToolCommand) nuget push --source $(NuGetFeedUrl) --api-key $(NuGetApiKey) --timeout $(NuGetPushTimeoutSeconds)</NuGetPushCommand>
44-
</PropertyGroup>
45-
46-
<ExecWithRetriesForNuGetPush Command="$(NuGetPushCommand) %(NuGetPackages.Identity)"
47-
IgnoredErrorMessagesWithConditional="@(IgnorableErrorMessages)" />
48-
</Target>
4912

5013
<Target Name="PublishSymbolPackages"
5114
Condition="'$(EnablePublishSymbols)'=='true'"

build/vsts-ci.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ phases:
189189
variables:
190190
BuildConfig: Release
191191
OfficialBuildId: $(BUILD.BUILDNUMBER)
192+
DotnetVersionKind: $[variables.VERSIONKIND] # If no "VERSIONKIND" variable is set when queuing the publishing task, this defaults to empty string.
192193
DOTNET_CLI_TELEMETRY_OPTOUT: 1
193194
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
194195
DOTNET_MULTILEVEL_LOOKUP: 0
@@ -230,33 +231,42 @@ phases:
230231
sourceFolder: $(Build.SourcesDirectory)/artifacts/pkgassets/PackageAssets
231232
targetFolder: $(Build.SourcesDirectory)/artifacts/pkgassets
232233

233-
- script: ./build.cmd -pack -configuration $(BuildConfig)
234+
# Depending on the value of DotNetFinalVersionKind, the name of the package will change.
235+
# For our nightly builds we want it to be empty, and when creating the official nugets, we want it to be "release"
236+
# the value of the version kind is set when queuing the publishing job on AzureDevOps by adding a VERSIONKIND variable
237+
# See more info in: https://github.com/dotnet/arcade/blob/master/Documentation/CorePackages/Versioning.md#package-version
238+
- script: ./build.cmd -configuration $(BuildConfig) -pack -ci /p:OfficialBuildId=$(OfficialBuildId) /p:DotNetFinalVersionKind=$(DotnetVersionKind) /p:RestorePackagesPath=$(Build.SourcesDirectory)\packages /p:NUGET_PACKAGES=$(Build.SourcesDirectory)\packages
234239
displayName: Build Packages
235240

236-
- script: ./sign.cmd /p:SignNugetPackages=true
241+
- script: ./sign.cmd /p:SignNugetPackages=true /p:RestorePackagesPath=$(Build.SourcesDirectory)\packages /p:NUGET_PACKAGES=$(Build.SourcesDirectory)\packages
237242
displayName: sign packages
238243
continueOnError: false
239244

240245
- task: NuGetAuthenticate@0
241246
inputs:
242247
nuGetServiceConnections: machinelearning-dnceng-public-feed # To allow publishing to a feed of another organization
243248

244-
- script: $(Build.SourcesDirectory)\.dotnet\dotnet.exe msbuild build\publish.proj /t:PublishPackages /p:NuGetFeedUrl=$(_AzureDevopsFeedUrl) /p:NuGetApiKey=AzureArtifacts
245-
displayName: Publish Packages to AzureDevOps Feed
249+
- task: NuGetCommand@2
250+
displayName: Push packages to AzureDevOps feed
251+
inputs:
252+
command: push
253+
packagesToPush: $(Build.SourcesDirectory)/artifacts/**/*.nupkg;!$(Build.SourcesDirectory)/artifacts/**/*.snupkg
254+
nuGetFeedType: external
255+
publishFeedCredentials: machinelearning-dnceng-public-feed
246256

247257
- task: MSBuild@1
248258
displayName: Publish Symbols to SymWeb Symbol Server
249259
inputs:
250260
solution: build/publish.proj
251-
msbuildArguments: /t:PublishSymbolPackages /p:SymbolServerPath=$(_SymwebSymbolServerPath) /p:SymbolServerPAT=$(SymwebSymbolServerPAT)
261+
msbuildArguments: /t:PublishSymbolPackages /p:SymbolServerPath=$(_SymwebSymbolServerPath) /p:SymbolServerPAT=$(SymwebSymbolServerPAT) /p:RestorePackagesPath=$(Build.SourcesDirectory)\packages /p:NUGET_PACKAGES=$(Build.SourcesDirectory)\packages
252262
msbuildVersion: 15.0
253263
continueOnError: true
254264

255265
- task: MSBuild@1
256266
displayName: Publish Symbols to Msdl Symbol Server
257267
inputs:
258268
solution: build/publish.proj
259-
msbuildArguments: /t:PublishSymbolPackages /p:SymbolServerPath=$(_MsdlSymbolServerPath) /p:SymbolServerPAT=$(MsdlSymbolServerPAT)
269+
msbuildArguments: /t:PublishSymbolPackages /p:SymbolServerPath=$(_MsdlSymbolServerPath) /p:SymbolServerPAT=$(MsdlSymbolServerPAT) /p:RestorePackagesPath=$(Build.SourcesDirectory)\packages /p:NUGET_PACKAGES=$(Build.SourcesDirectory)\packages
260270
msbuildVersion: 15.0
261271
continueOnError: true
262272

src/Microsoft.ML.SamplesUtils/Microsoft.ML.SamplesUtils.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<IncludeInPackage>Microsoft.ML.SampleUtils</IncludeInPackage>
77
<PackageDescription>Sample utils for Microsoft.ML.Samples</PackageDescription>
8+
9+
<!--The nuget we publish is named SampleUtils, so this is necessary.
10+
Still, the namespace expected inside the nuget is named SamplesUtils,
11+
So the project itself and its code is not to be renamed SampleUtils.-->
12+
<PackageId>Microsoft.ML.SampleUtils</PackageId>
813
</PropertyGroup>
914

1015
<ItemGroup>

0 commit comments

Comments
 (0)