Search code examples
tfsnugettfsbuild

How to copy nupkg from build process to drop folder


TL/DR: In a release step, how do I find a .nupkg file that was definitely created in a build process and copy it to a drop folder for use in a release task?

Using TFS 2018, I am trying to copy a .nupkg file created in a prior Build task to the drop folder.

...In the Build Process...

From the log, I know that the file was created.

Successfully created package 'C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg'.

What I am trying to figure out is how I can find this file and copy it to the drop folder. Using Build Variables for inspiration, I have tried the following. At first, I thought it was successful because of what the log said.

  • Source Folder: $(Agent.BuildDirectory)
  • Contents: *\*.nupkg
  • Target Folder: drop

  • Result:

found 1 files Copying C:\agent_work\9\a\StaticHelpers.1.0.0.nupkg to drop\a\StaticHelpers.1.0.0.nupkg

All that means is that I can create a release process that takes that file and copies it in a copy release step, right?

...In the Release Process...

Not right. There is nothing in the drop folder when I created a copy file release task and tried to select the nuget package that was definitely created in the build. What I need to do is take that *.nupkg file created during the Build process and copy it to a network share.

enter image description here

So I tried to hard-code the folder based on what I copied from the build log.

  • Source Folder: drop\a

The release failed, showing this in the log:

[error]Unhandled: Not found SourceFolder: C:\agent_work\r4\a\drop

Either I am copying the file to the wrong location or I am reading from the wrong location. What folders do I need to use so that I can see the *.nupkg file in my release task?


Solution

  • In your build process, don't use a Copy Files task, use a Publish Artifacts task. That will publish an artifact "attached" to the build that a release will automatically pick up during deployment.