6

Is it possible to specify the target framework for a ClassLibrary project using Azure Devops Build Pipelines and the DotNetCoreCLI@2 task? Or do we have to revert to using a script and manually calling the dotnet publish command?

A snippet from my pipeline YAML

variables:
  buildConfiguration: 'Debug'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish' 
    publishWebProjects: false # Required when command == Publish
    projects: 'TestProject/Test/Test.csproj'
    configuration: '$(BuildConfiguration)'

And from my .csproj:

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;net45</TargetFrameworks>
  </PropertyGroup>

I'm using the documentation here for the DotNetCoreCLI@2 task but it's not always great.

EDIT: I should add that at the moment the Build completely fails because:

The 'Publish' target is not supported without specifying a target framework. 
The current project targets multiple frameworks, please specify the framework 
for the published application. 
1
  • Hello @JLo ; a side question : Did you try to set buildConfiguration: 'Release' ? Because when I do this, the build is using 'Debug' Commented Oct 11, 2018 at 19:31

1 Answer 1

7

The DotNetCoreCLI@2 task could be extended with the arguments property, on which you could specify the framework (as well as the build configuration):

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish' 
    publishWebProjects: false # Required when command == Publish
    projects: 'TestProject/Test/Test.csproj'
    arguments: '--configuration $(BuildConfiguration) --framework netcoreapp2.1'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.