timblistic
timblistic

Reputation: 581

Why difference in publish output between visual studio 2017 and azure devops in .net core 2.1?

When trying to publish my .net core mvc application to a folder, it is IIS friendly whereas when i tried to publish the same source in azure devops pipelines, it creates almost hundreds of files which is not IIS friendly. Why both differs or what i need to do to have azure publish works the same way as visual studios.

Have gone through troubleshooting azure documentation and couldnt find it useful to this problem.

Adding azure-pipeline.yml content below

    trigger:
    - dev

    pool:
      vmImage: 'Ubuntu-16.04'

    variables:
      buildConfiguration: 'Release'
      a: dotnet --version

    steps:
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'
    - bash: echo $(a)

    - task: DotNetCoreCLI@2
      inputs:
        command: publish
        publishWebProjects: True
        arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
        zipAfterPublish: True

    - task: PublishBuildArtifacts@1
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
        artifactName: 'Vinocopia_Redesign'

    - task: FtpUpload@1
      inputs:
        credentialsOption: 'inputs'
        serverUrl: 'ftp://xx.xx.xx.xx'# Required when credentialsOption == Inputs
        username: 'username'# Required when credentialsOption == Inputs
        password: 'pwd'# Required when credentialsOption == Inputs
        rootDirectory: 
        filePatterns: '**' 
        remoteDirectory: '/upload/$(Build.BuildId)/' 
        #clean: false 
        #cleanContents: false # Required when clean == False
        overwrite: false 
        #preservePaths: false 
        #trustSSL: false 

Upvotes: 0

Views: 1081

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30323

Why difference in publish output between visual studio 2017 and azure devops in .net core 2.1?

Just like D.J pointed:

"dotnet publish" and "vs publish" are differenz methods of publishing

If you want get the same result with you get from Visual Studio publish, you should use Visual Studio/MSBuild publish instead of dotnet publish, so we need use Visual Studio build with MSBuild arguments like following:

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: NetCoreMVC/NetCoreMVC.sln
    msbuildArgs: '/p:DeployOnBuild=true  /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:publishUrl="$(Build.ArtifactStagingDirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

Hope this helps.

Upvotes: 1

Related Questions