如何获得Azure DevOps为.net标准2.0项目创建正确的nuspec? [英] How do I get Azure DevOps to create a correct nuspec for a .net standard 2.0 project?

查看:88
本文介绍了如何获得Azure DevOps为.net标准2.0项目创建正确的nuspec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过右键单击VS2019中的项目并选择包,我可以为.net标准2.0库创建合适的nuget包。

I can create a proper nuget package for my .net standard 2.0 library by right clicking the project in VS2019 and selecting pack.

.nuspec包含

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>SBD.Standard</id>
    <version>1.0.0</version>
    <authors>SBD.Standard</authors>
    <owners>SBD.Standard</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework=".NETStandard2.0">
        <dependency id="Microsoft.Data.SqlClient" version="1.1.0" exclude="Build,Analyzers" />
        <dependency id="Microsoft.EntityFrameworkCore" version="3.1.1" exclude="Build,Analyzers" />
        <dependency id="Microsoft.EntityFrameworkCore.SqlServer" version="3.1.1" exclude="Build,Analyzers" />
        <dependency id="Newtonsoft.Json.Schema" version="2.0.7" exclude="Build,Analyzers" />
        <dependency id="RestSharp" version="106.10.0" exclude="Build,Analyzers" />
        <dependency id="System.Data.SqlClient" version="4.6.1" exclude="Build,Analyzers" />
      </group>
    </dependencies>
  </metadata>
</package>

但是,如果我在azure-pipelines.yml中使用以下命令在Azure Devops中创建nuget,

However if I create the nuget in Azure Devops using the following command in azure-pipelines.yml

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/SBDSTD.*.csproj'

然后我查看创建的包的.nuspec文件它包含

Then I look at the .nuspec file for the package created it contains

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
  <metadata>
    <id>SBD.Standard</id>
    <version>2.0.0-CI-20200212-174043</version>
    <title>SBD.Standard</title>
    <authors>SBD.Standard</authors>
    <owners>SBD.Standard</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description</description>
    <dependencies />
  </metadata>
</package>

如何让Devops创建正确的.nuspec文件?

How do I get Devops to create the correct .nuspec file?

推荐答案


如何获取Azure DevOps为.net标准2.0项目创建正确的nuspec?

How do I get Azure DevOps to create a correct nuspec for a .net standard 2.0 project?

在与Kirsten Greed进行了长时间的故障排除后,我们解决了这个问题。

After a long troubleshooting with Kirsten Greed, we figured it out.

我们在YAML之后将其解决为.net标准2.0项目重新生成nuget软件包:

We resolve this following YAML to regenerate the nuget package for a .net standard 2.0 project:

trigger: none
pool:
  vmImage: vs2017-win2016

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: xxxx/xxx.csproj
    vstsFeed: 'XXXXXXX'

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: xxx/xxx.csproj
    arguments: '/p:Configuration=Release'

- task: DotNetCoreCLI@2
  displayName: 'dotnet pack'
  inputs:
    command: pack
    packagesToPack: xxx/xxx.csproj

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

然后,我们可以在解压缩生成的包后检查 .nuspec 文件。

Then we could check the .nuspec file after unzipping the generated package.

此外,我们可以使用nuget push任务将生成的包发布到Feed中,例如:

In addition, we could use nuget push task to publish the generated package to our feed, like:

- task: DotNetCoreCLI@2
displayName: 'dotnet push'
inputs:
command: push
publishVstsFeed: 'XXXX'

希望这会有所帮助。

这篇关于如何获得Azure DevOps为.net标准2.0项目创建正确的nuspec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆