我可以在同一存储库中混合使用框架项目和.net标准项目吗?点网包命令 [英] Can I mix framework projects and .net standard projects in the same repository? Dotnet Pack command

查看:68
本文介绍了我可以在同一存储库中混合使用框架项目和.net标准项目吗?点网包命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该问题的答案中需要将构建Yaml从使用Nuget更改为使用DotNet 这样.net标准项目就可以正确打包(我希望).但是,当我这样做时,我开始变得

In the answer to this question I needed to change the build yaml from using Nuget to using DotNet So that the .net standard project would pack correctly ( i hope ). However when I did this I started getting

错误MSB4057:项目中不存在目标包装"

error MSB4057: The target "pack" does not exist in the project

用于框架项目.

我应该分离存储库,还是可以通过某种方式为不同的目标指定不同的打包命令?

Should I be separating the repositories or is there some way to specify different pack commands for different targets?

我最初的azure-pipelines.yml是

My original azure-pipelines.yml was

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  Major: '2'
  Minor: '0'
  Patch: '0'

steps:
- task: NuGetToolInstaller@0
  inputs:
    versionSpec: '>=4.3.0'
    checkLatest: true

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: NuGetCommand@2
  inputs:
    command: pack
    packagesToPack: '**/*.csproj'
    versioningScheme: byPrereleaseNumber
    majorVersion: '$(Major)'
    minorVersion: '$(Minor)'
    patchVersion: '$(Patch)'

- task: NuGetCommand@2
  inputs:
    command: pack
    packagesToPack: '**/*.vbproj'
    versioningScheme: byPrereleaseNumber
    majorVersion: '$(Major)'
    minorVersion: '$(Minor)'
    patchVersion: '$(Patch)'

- task: NuGetCommand@2
  displayName: 'NuGet push'
  inputs:
    command: push
    publishVstsFeed: 'SBDCommonFeed'
    allowPackageConflicts: true

但是我将NuGetCommand @ 2任务更改为

but I changed the NuGetCommand@2 task to be

- task: DotNetCoreCLI@2
  inputs: 
    command: 'pack'
    outputDir: '$(Build.ArtifactStagingDirectory)/TestDir'

对于Nuget命令,我可以尝试使用PackagesToPack 我对DotNet命令有什么更改?

For the Nuget command I can experiment with PackagesToPack What do I change for the DotNet command?

[更新] 我尝试过

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    projects: '**/*Standard.csproj'
    outputDir: '$(Build.ArtifactStagingDirectory)/OutputDir'

其中* Standard是.net标准项目.但是,框架项目上仍然存在MSB4057错误

Where *Standard are the .net standard projects. However there was still the MSB4057 error on a framework project

推荐答案

该错误表明您正在尝试打包.net standard项目和.net framework项目,而您只需要打包.net标准库项目. (此外,dotnet pack不应用于打包一个非库项目.)

The error indicates you're trying to pack both the .net standard project and .net framework project while you only need to pack the .net standard library project. (Also, dotnet pack should not be used to pack one non-library project.)

因此,解决方法是在使用dotnet pack任务时指定要打包的项目.

So the workaround is to specify the project to pack when using dotnet pack task. The Pack command in .net core task also supports packagesToPack element.

请参见#packagesToPack: '**/*.csproj' # Required when command == Pack.

通常的格式是:

steps:

- task: DotNetCoreCLI@2  
  displayName: 'dotnet pack'
  inputs:
    command: pack
    packagesToPack: '**/ProjectName.csproj'
    configuration: Release
    versioningScheme: xxx
    minorVersion: xxx
    buildProperties: xxx
    ...

这篇关于我可以在同一存储库中混合使用框架项目和.net标准项目吗?点网包命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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