0

I have a console .netframework ( not .net core) application which I'm trying to build in Azure pipeline. I believe the compliation goes through. But I need help with:

  1. Generating a single file ( if possible )
  2. Publishing the artifact to the artifact directory.

The publishartifact fails with this error: ##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'TestConsoleOwinSelfHosted'.

I have looked at this but this just copied the entire source directory to the staging directory.

Here is my yaml:

trigger:
- master

stages:
  - stage: build
    displayName: build solution
    variables:
      solution: '**/*.sln'
      buildPlatform: 'any cpu'
      buildConfiguration: 'release'
     
    jobs:
      - job: build
        displayName: build Job
        pool:
          name: Azure Pipelines
          vmImage: 'windows-latest'
          demands:
            - msbuild
            - visualstudio
            - vstest
       
        steps:
        - task: NuGetToolInstaller@0
          displayName: 'Use NuGet 5.8.0'
          inputs:
            versionSpec: 5.8.0
 
        - task: NuGetCommand@2
          displayName: 'NuGet restore'
          inputs:
            restoreSolution: '$(solution)'
 
        - task: VSBuild@1
          displayName: 'Build solution '
          inputs:
            solution: '$(solution)'
            platform: '$(buildPlatform)'
            configuration: '$(buildConfiguration)'
        
        - task: PublishBuildArtifacts@1
          inputs:
            PathtoPublish: '$(Build.ArtifactStagingDirectory)'
            ArtifactName: 'TestConsoleOwinSelfHosted'
            publishLocation: 'Container'

Here is the output of the VSBuild task:

Starting: Build solution ============================================================================== Task : Visual Studio build Description : Build with MSBuild and set the Visual Studio version property Version : 1.187.0 Author : Microsoft Corporation Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build ============================================================================== "D:\a_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.187.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "D:\a\1\s\TestConsoleOwinSelfHosted.sln" /nologo /nr:false /dl:CentralLogger,"D:\a_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.187.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=9378f684-8bb9-4d5e-b61b-d20be97f03a7|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.187.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="16.0" /p:_MSDeployUserAgent="VSTS_fa860a9a-7abc-4169-b8fc-d94a1991ceb4_build_1_0" Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch. Build started 7/7/2021 11:39:39 PM. Project "D:\a\1\s\TestConsoleOwinSelfHosted.sln" on node 1 (default targets). ValidateSolutionConfiguration: Building solution configuration "release|any cpu". Project "D:\a\1\s\TestConsoleOwinSelfHosted.sln" (1) is building "D:\a\1\s\TestConsoleOwinSelfHosted\TestConsoleOwinSelfHosted.csproj" (2) on node 1 (default targets). PrepareForBuild: Creating directory "bin\Release". Creating directory "obj\Release". GenerateBindingRedirects: No suggested binding redirects from ResolveAssemblyReferences. CoreCompile: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /fullpaths /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\Microsoft.CSharp.dll" /reference:D:\a\1\s\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll /reference:D:\a\1\s\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll /reference:D:\a\1\s\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\mscorlib.dll" /reference:D:\a\1\s\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll /reference:D:\a\1\s\packages\Owin.1.0\lib\net40\Owin.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Net.Http.dll" /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\TestConsoleOwinSelfHosted.exe /subsystemversion:6.00 /target:exe /utf8output /deterministic+ /langversion:7.3 Program.cs Properties\AssemblyInfo.cs Startup.cs ValuesController.cs "obj\Release.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" CompilerServer: server - server processed compilation - 48a4bca3-f083-4c70-aff0-96988cb31d8d _CopyFilesMarkedCopyLocal: Copying file from "D:\a\1\s\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Newtonsoft.Json.dll". Copying file from "D:\a\1\s\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.dll". Copying file from "D:\a\1\s\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.Host.HttpListener.dll". Copying file from "D:\a\1\s\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.Hosting.dll". Copying file from "D:\a\1\s\packages\Owin.1.0\lib\net40\Owin.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Owin.dll". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Net.Http.Formatting.dll". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Web.Http.dll". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Web.Http.Owin.dll". Copying file from "D:\a\1\s\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.xml". Copying file from "D:\a\1\s\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.Host.HttpListener.xml". Copying file from "D:\a\1\s\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Microsoft.Owin.Hosting.xml". Copying file from "D:\a\1\s\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\Newtonsoft.Json.xml". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Net.Http.Formatting.xml". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Web.Http.xml". Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.xml" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\System.Web.Http.Owin.xml". Creating "D:\a\1\s\TestConsoleOwinSelfHosted\obj\Release\TestConsoleOwinSelfHosted.csproj.CopyComplete" because "AlwaysCreate" was specified. _CopyAppConfigFile: Copying file from "D:\a\1\s\TestConsoleOwinSelfHosted\App.config" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\TestConsoleOwinSelfHosted.exe.config". CopyFilesToOutputDirectory: Copying file from "D:\a\1\s\TestConsoleOwinSelfHosted\obj\Release\TestConsoleOwinSelfHosted.exe" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\TestConsoleOwinSelfHosted.exe". TestConsoleOwinSelfHosted -> D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\TestConsoleOwinSelfHosted.exe Copying file from "D:\a\1\s\TestConsoleOwinSelfHosted\obj\Release\TestConsoleOwinSelfHosted.pdb" to "D:\a\1\s\TestConsoleOwinSelfHosted\bin\Release\TestConsoleOwinSelfHosted.pdb". Done Building Project "D:\a\1\s\TestConsoleOwinSelfHosted\TestConsoleOwinSelfHosted.csproj" (default targets). Done Building Project "D:\a\1\s\TestConsoleOwinSelfHosted.sln" (default targets).

Prashant Saraswat
  • 838
  • 1
  • 8
  • 20
  • 2
    You need to copy the contents of SolutionDir/bin/Release to the artifact staging directory. You can use a file copy task with a glob pattern to do that `$(Build.SourcesDirectory)/**/bin/Release/*.*` or similar – pinkfloydx33 Jul 08 '21 at 00:41
  • Fody/Costura does the job of combining the dependencies into the executable as described here: https://stackoverflow.com/questions/189549/embedding-dlls-in-a-compiled-executable. Also as @pixkfloydx33 mentioned the desired files can be copied by just adjusting the path. Thank you!! – Prashant Saraswat Jul 08 '21 at 15:33

0 Answers0