OctoPack works fine creating packages using both VisualStudio, or msbuild. I wanted to separate the package creation from building the project. So I tried to run just the OctoPack target after the project was built:
MSBUILD : OctoPack error OCTONUGET: Cannot create a package that has no dependencies nor content.
MSBUILD : OctoPack error OCT-1676060969: There was an error calling NuGet. Please see the output above for more details. Command line: …
MSBUILD : OctoPack error OCT-1676060969: System.Exception: There was an error calling NuGet. Please see the output above for more details. Command line: …
MSBUILD : OctoPack error OCT-1676060969: at OctoPack.Tasks.CreateOctoPackPackage.RunNuGet(String specFilePath, String octopacking, String octopacked, String projectDirectory) in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 551
MSBUILD : OctoPack error OCT-1676060969: at OctoPack.Tasks.CreateOctoPackPackage.Execute() in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 188
It in fact created a .nuspec that had an empty list.
Should running just the OctoPack target work at all? Or it only works as part of a regular build?
Thanks for getting in touch! You can run it outside of the build, but the syntax is slightly different than that in the build configuration. msbuild MyLocalService.csproj /t:OctoPack /p:RunOctoPack=true /p:OctoPackPublishPackageToFileShare=..\..\NugetFileRepo64
The above should work.
But breaking up the build parameters into multiple /p options does not make msbuild run any different.
In addition you’ve dropped the Configuration and Platform parameters, which makes things worse - msbuild looks into a default location (bin\Debug) where there are no assemblies. The correct location is bin\x64\Debug, which it figures correctly when the Configuration and Platform parameters are given.
Ah, yeah sorry about that. Octopack needs a build to package. While it can be done on command line, it still needs /t:build to run and /p:RunOctopack=true
It just cannot be separated as the build creates the targets for the package. It can however be run manually via command
So : msbuild MyLocalService.csproj /t:Build /p:RunOctoPack=true with any other options required.
Because our projects only use asssembly references instead of project references, we are able to create a solution (sln) that contains only the projects that use OctoPack.
We have an AllProjects.sln which includes all 123 projects and this solution is used for the main build process without packaging (RunOctoPack=false)
We also have an OctoPackProjects.sln which includes only the 20 OctoPack projects and we use this solution for OctoPack packaging purposes. Because the main AllProjects.sln has already built everything, whenever we run
msbuild OctoPackProjects.sln /p:Configuration=Release /p:RunOctoPack=true /p:OctoPackPackageVersion=%env.BUILD_NUMBER%
the CoreCompile steps shows:
CoreCompile:
Skipping target “CoreCompile” because all output files are up-to-date with respect to the input files.
So in the end we are able to package only if every other build step succeeds.