0

I am using the following as a post build event:

FOR %%a in ($(ProjectDir)$(OutDir)MyLibrary.*.dll) DO CALL :package %%~na

:package 
"$(SolutionDir)\..\..\..\Packages\NuGet.exe" pack "$(SolutionDir)%1\%1.csproj" -o "$(SolutionDir)\..\..\..\Packages"

The function of the above is to find all MyLibrary dll's in a folder and create a nuget package from them. There are 5 files that match the search for MyLibrary.*.dll. However only 1 package gets created - the first file found.

Anyone see any issue with the above as to why its only creating one package and not 5. Is there a syntax error?

amateur
  • 43,371
  • 65
  • 192
  • 320

1 Answers1

0

You are missing the goto :eof call after the NuGet line; which signifies the end of the :package function. Therefore, the loop is calling the function, but the function is never returning to the loop.

FOR %%a in ($(ProjectDir)$(OutDir)MyLibrary.*.dll) DO CALL :package %%~na
goto End

:package 
"$(SolutionDir)\..\..\..\Packages\NuGet.exe" pack "$(SolutionDir)%1\%1.csproj" -o "$(SolutionDir)\..\..\..\Packages"
goto :eof

:End
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47
  • 1
    I think there should also be a `goto :eof` after the `for` statement, otherwise the `:package` code runs again after the loop, but with different arguments… – mousio Dec 09 '12 at 14:21
  • @mousio correct, there should also be a goto to pass over the function so that it is not run again or a goto :eof to end the script at that point. – David Ruhmann Dec 09 '12 at 23:29