Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

DevOps - dotnet publish Release fails (for server side project) #7965


User avatar
0
ray created

Hi,

Any ideas on this one as I’m still struggling on this issue in my devops yaml file where it keeps failing on the ‘dotnet publish Release’

I have even tried putting in target conditions in the csproj files in the server side projects but still the same…

Restore completed in 54.54 ms for d:\a\1\s\src\WipTrack.Core.Shared\WipTrack.Core.Shared.csproj. Restore completed in 54.38 ms for d:\a\1\s\src\WipTrack.Application.Shared\WipTrack.Application.Shared.csproj. C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.CrossTargeting.targets(27,5): error : 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. [d:\a\1\s\src\WipTrack.Application.Shared\WipTrack.Application.Shared.csproj]

This is my yaml file, is there anything in here I need to change or anything in the server side solution i need to change?

======================================================================= trigger:

  • master

pool: vmImage: 'windows-2019'

variables: buildConfiguration: 'Release' workingDirectory: '$(Build.SourcesDirectory)/src'

steps:

  • script: dotnet restore ./WipTrack.Web.Host displayName: Restore workingDirectory: $(workingDirectory)

  • script: dotnet build ./WipTrack.Web.Host --configuration $(buildConfiguration) displayName: Build workingDirectory: $(workingDirectory)

  • task: DotNetCoreCLI@2 displayName: Run Unit Tests inputs: command: test projects: '**/Tests/.csproj' arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'

  • task: DotNetCoreCLI@2 displayName: 'dotnet publish $(buildConfiguration)' inputs: command: publish projects: '**/*.csproj' publishWebProjects: false arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: true workingDirectory: $(workingDirectory)

  • task: PublishBuildArtifacts@1 displayName: 'publish artifacts' =====================================================================================

I tried putting in target conditions in the csproj files for the netstandard projects to include netcore2.2 and teh solution builds fine, but back in devops its still fails with the same error at the dotnet publish

Thanks.


1 Answer(s)
  • User Avatar
    0
    ray created

    I got this working, had to define the exact project not all csproj, so i basically changed this...

    task: DotNetCoreCLI@2 displayName: 'dotnet publish $(buildConfiguration)' inputs: command: publish projects: '**/*.csproj' publishWebProjects: false arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: true workingDirectory: $(workingDirectory)

    to this...

    • task: DotNetCoreCLI@2 displayName: 'dotnet publish $(buildConfiguration)' inputs: command: publish projects: '**/WipTrack.Web.Host.csproj' publishWebProjects: false arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' zipAfterPublish: true workingDirectory: $(workingDirectory)