0

I have created an Azure DevOps 2022 pipeline to build a .Net 7 application. At one point during my creation of this pipeline, it was properly building the application, packaging it into a single-file executable, then zipping it and its pdb's (and config files) into a nice package. At some point this stopped working and I am not sure what changed. Now, for the life of me, I cannot get this pipeline to build the single-file executable (and consequently, no zip file is created).

The code is indeed successfully compiled and I am left with an executable with all associated DLLs as I would expect normally on the build agent which are moved into the artifact location.

I have researched this for days and have been unable to figure out what's wrong. I have looked at this article, and this one, and this one too, plus a few others. I have ensured that my Build step command is "publish" and have tried every combination of using -p:PublishSingleFile and --self-contained, and ensured that I am specifying -r win-x64. Yet this still refuses to work. I have looked over verbose Msbuild output very closely and found no clues as to why this refuses to build.

Here is the YAML for the build step:

- task: DotNetCoreCLI@2
  displayName: 'Build MoverSvc single-file executable'
  inputs:
    command: publish
    publishWebProjects: false
    projects: 'MoverSvc\MoverSvc.csproj'
    arguments: '-c Release -r win-x64 -p:PublishSingleFile=True --output $(Build.ArtifactStagingDirectory) --self-contained false'

This must be my fault, but just can't seem to find what I missed/changed/broke. Thanks for any help or direction you can provide me.

bodylice
  • 25
  • 5

1 Answers1

0

Well I figured this out. As I suspected, it was my fault, not the fault of any issue in Azure DevOps. I still wanted to share my solution in case it helps someone else.

I was creating my zipped single-file executable in $(build.artifactstagingdirectory). Then in a later step ('Copy files to:') I was copying all other build files to $(build.artifactstagingdirectory) and I had the option to Clean Target Folder selected which was essentially deleting my zips. So when the 'Publish Artifact: drop' step completed and I checked my artifact location, there were of course no zip files.

I am new to Azure DevOps and only figured this out when I started studying and closely watching the build location and its subfolders and contents on the build agent server and saw my zip file created... and then deleted, during a pipeline run.

So learn how the build process works, where the builds are created on the build agent server, what folders are involved and understand how and when contents are moved between them. It may save you some pain in the future. As I mentioned before, I hope this helps someone else out. Have a great day everyone.

bodylice
  • 25
  • 5