我使用自动休息为Azure函数生成客户端Sdk。
之后,应该打包客户端Sdk并将其推送到我们的nuGet提要中。
这些步骤都将通过一个用于Azure DevOps的yaml管道来完成。
,这在过去的几个月里真的很好。但是最近Autorest停止了正常工作。
不幸的是,autorest生成一个需要β nuGet包的项目文件。
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20210205.2" />当然,nuGet包不能打包带有beta或预发布依赖关系的项目。
生成的项目文件如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>annotations</Nullable>
</PropertyGroup>
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<RestoreAdditionalProjectSources>https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20210205.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.6.0" />
</ItemGroup>
</Project>生成、打包和推送客户端Sdk的管道如下所示:
steps:
- powershell: 'npm install -g autorest@latest'
displayName: "Install AutoRest"
- task: AzurePowerShell@4
displayName: "Download Swagger"
inputs:
azureSubscription: ${{parameters.subscription}}
scriptType: 'InlineScript'
azurePowerShellVersion: 'LatestVersion'
inline: |
$context = New-AzApiManagementContext -ResourceGroupName "${{parameters.apimResourceGroup}}" -ServiceName "${{parameters.apim}}"
Export-AzApiManagementApi -Context $context -ApiId "$(appName)-development" -SpecificationFormat OpenApi -SaveAs "$(Build.ArtifactStagingDirectory)\definition-$(version).yaml"
- powershell: 'autorest --verbose --v3 --csharp --add-credentials --input-file="$(Build.ArtifactStagingDirectory)\definition-$(version).yaml" --output-folder="$(Build.Repository.LocalPath)\Api\src\ClientSdk" --namespace="ClientSdk" --override-client-name="Client"'
displayName: 'Run AutoRest'
- task: DotNetCoreCLI@2
displayName: "Pack Projects"
inputs:
command: "pack"
arguments: "--configuration $(buildConfiguration) --include-symbols"
packagesToPack: "**/ClientSdk.csproj"
versioningScheme: "off"
verbosityPack: "Normal"
- task: DotNetCoreCLI@2
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;!$(Pipeline.Workspace)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: ${{parameters.nugetfeed}}此错误导致nuGet包任务失败
1>C:\Program Files\dotnet\sdk\5.0.102\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(207,5): error NU5104: A stable release of a package should not have a prerelease dependency. Either modify the version spec of dependency "Microsoft.Azure.AutoRest.CSharp [3.0.0-beta.20210205.2, )" or update the version field in the nuspec.
发布于 2021-02-10 03:40:19
在发布包中使用预发布包是不稳定和危险的。存在此错误是为了防止这种情况发生。您可以使用以下几个选项:
将您的包标记为预发行版
假设您的项目仍在开发中,并且需要利用仍在开发中的最新依赖项,只需将您的包标记为开发中的包即可。来自微软文档
如果您的项目使用PackageReference:在.csproj文件的PackageVersion元素中包含语义版本后缀: 1.0.1-alpha 如果您的项目有一个packages.config文件:在.nuspec文件的version元素中包含语义版本后缀: 1.0.1-alpha
使用最后一个稳定构建的
回到使用发布包的依赖项的最后一个版本。这通常是比较安全的,因为在开发依赖项中可能会引入一些尚不清楚的严重问题.如果项目开发人员认为他们的项目对生产使用是安全的,他们就会将其标记为安全。
https://stackoverflow.com/questions/66127390
复制相似问题