0
votes

My .sln consists of several projects (.cspoj) with a mix of targeting frameworks including .netcore and a selection of .net frameworks.

Some of these projects are web projects which need to be built and include other non-web projects in their packages.

This is essentially a teamcity to azure devops migration - I figured using vsbuild and then dotnetcorecli 'publish' would give me the required packages (publish command does find the correct webapps).

My issue is that after VSBuild I have oneproject.zip in my "artifact staging dir", the dotnet publish command afterwards, which is set to output into "artifact staging dir/publish", simply erases all content from "oneproject.zip" and then complains it cannot find "oneproject", please see the error output below the pipeline.

Here is my annotated and condensed pipeline

pool: selfhosted

using a self hosted agent, with msbuildtools/vs studio/node/npm

variables:
  solution: '**/mainsolution.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Debug'

global variables

stages:
    - stage: build_main
      displayName: 'Build Main'
      jobs:

using stages, to prevent overwriting source files by grouping tasks

      - job: multijob
        steps:
        - task: NuGetToolInstaller@1
          displayName: 'install nuget'
        - task: NuGetCommand@2
          displayName: 'NuGet restore'
          inputs:
            command: 'restore'
            restoreSolution: '$(solution)'
            feedsToUse: 'select'
            vstsFeed: 'myvstsfeed'

installing nuget, and restoring from an azure artifacts feed

        - task: DotNetCoreCLI@2
          displayName: 'dotnet restore'
          inputs:
           command: 'restore'
           projects: '**/mainsolution.sln'
           feedsToUse: 'select'
           vstsFeed: 'myvstsfeed'

VSBuild - Building the main .sln which references all .csproj's, and a separate MSBuild for another odd project.*

        - task: VSBuild@1
          displayName: 'Build Solution'
          inputs:
            solution: '$(solution)'
            msbuildArgs: '
            /p:DeployOnBuild=true 
            /p:WebPublishMethod=Package 
            /p:PackageAsSingleFile=true 
            /p:SkipInvalidConfigurations=true 
            /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
            platform: '$(BuildPlatform)'
            configuration: '$(BuildConfiguration)'
        - task: VSBuild@1
          displayName: 'Build oddproject'
          inputs:
            solution: '**/oddproject/oddproject.csproj'
            msbuildArgs: '
            /p:DeployOnBuild=true 
            /p:WebPublishMethod=Package 
            /p:PackageAsSingleFile=true 
            /p:SkipInvalidConfigurations=true 
            /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
            platform: '$(BuildPlatform)'
            configuration: '$(BuildConfiguration)'

This is the problem, my publish step

        - task: DotNetCoreCLI@2
          inputs:
           command: 'publish'
           publishWebProjects: true
           arguments: '--configuration $(BuildConfiguration) -o published'

##[debug]Zip arguments: Source: published\oneproject , target: published\oneproject.zip

##[error]Error: ENOENT: no such file or directory, open 'A:\agent_work\2\s\published\oneproject.zip'


  1. why is it looking for a source directory in my output folder and not a .zip from VSBuild's output?
  2. why does it delete the zip files contents?
  3. I was unable to specify vsbuild to output into the filesystem without zipping.
  4. trying an extract command failed, as the zip is extracted excluding the project name (straight to content). Also using a ramdisk for my _work, so would prefer a more memory managed approach.

I really appreciate any inputs or critique on this. Let me know if there's anything useful I can provide as well. <3

1
In teamcity - the one thing I could not migrate is "Artifact paths:", which has the following structure - oneproject/obj/%Configuration%/Package/PackageTmp/** => %Configuration%_%build.number%/oneproject.zip It has these for the few webprojects I need. Is there a way to set this in devops before vsbuild?Puzis

1 Answers

0
votes

Looks like "oneproject.csproj" wasn't a solution that could be built with dotnetcorecli. After isolating the correct projects to separate into vsbuild and dotnetpublish - the build progressed. I then had node and gulp issues, but those were solved by installing an older version (or any version from a build machine able to build it, node/gulp -v).

I solved the artifact path issue by manually archiving the output of every vsbuild webproject's 'packagetmp' folder into artifact staging.