AndreyS
AndreyS

Reputation: 385

Matching pattern does not work in NuGet Packager

I have multiple .csproj files in my git source folder and its subfolders. I want to create NuGet packages for all of them. If I understand things correctly, I should add NuGet Packager build step and configure its Path to csproj or nuspec file(s) to pack to be

**\*.csproj

But no packages get created when I run my build. By the way, if I manually select some 'csproj' file using "..." button and run build then package for it will be created.

Could anyone explain why I cannot use **\*.csproj matching pattern to create packages for all projects in my source directory and its subdirs? Is there any limit for nesting level or something? At least I have couple csproj files on maximum nested level 4-5 counting from the source folder...

p.s. I know there was a similar bug about Exclusion pattern not working for vsts build so I wonder if it's a related issue?

See my build configuration and log of my NuGet Packager and NuGet Publisher build steps where D:_work\3\s is the folder on a build server where it cannot find csproj files. Although I can see files there, for example the first is on D:_work\3\s\Source\Product\Components\Folder1\MyProj1.csproj, the second on D:_work\3\s\Source\Product\Components\Folder2\MyProj2.csproj, etc... enter image description here enter image description here

Upvotes: 0

Views: 770

Answers (2)

Floris Devreese
Floris Devreese

Reputation: 3667

I had a similar issue. The NuGet Pack task finishes successfully, but didn't create a NuGet package. In the task logging (when running with debug=true) I see the following:

...
##[debug]found 8037 paths
##[debug]applying include pattern
##[debug]0 matches
...

The NuGet Pack task doesn't create a package because it didn't find any .csproj or .nuspec file. In my case the reason it didn't find any .csproj or .nuspec file is because the work folder of my build agent is set to ".". I found this when analysing the pattern in the logs of the NuGet Pack task.

...
##[debug]pattern: 'D:\Agents\agent_1\.\123\s\*.nuspec'
...

The fix for this issue is changing the workFolder in the .agent file of the build agent. You can find this in the root folder of the build agent (e.g. D:\Agents\agent_1\.agent). Originally this was:

{
  "agentId": 48,
  "agentName": "agent_1",
  "poolId": 3,
  "serverUrl": "<TFS url>",
  "workFolder": "."
}

And you have to change it to

{
  "agentId": 48,
  "agentName": "agent_1",
  "poolId": 3,
  "serverUrl": "<TFS url>",
  "workFolder": "D:\\Agents\\agent_1"
}

Be sure to restart the build agent windows service after changing this file!

Hope this helps :-)

Upvotes: 0

DenverDev
DenverDev

Reputation: 497

The level of nesting should not be an issue. I was able to setup a test project with 3 Projects at various levels and the single NuGet Task created a NuGet package for all of them.

Here is the configuration I used (It is the default configuration at this point in time). This was done using version 2.x of the task, so if you are using an earlier version you may want to upgrade.

Nuget Pack

You can also watch exactly what is happening during this step by setting system.debug = true when you queue the build. After you do this, you can look into the log for the Nuget Pack step and you should see it iterating through all of your directories and sub-directories and flagging those that match. Here you can see that it found and then continues to pack these 3 projects.

Post your detailed setup and log here if you still need additional assistance.

VSTS Output Log

Upvotes: 0

Related Questions