I have a windows service which I am bundling with Octopack 3.0.23. One of the solution projects outputs an executable named Foo.exe. Project post build copies Foo.exe over to bar.exe. Bar.exe is now in the service project bin folder as a build artifact. So I added the following to the project nuspec file hoping Octopack knows to now bundle it:
<files>
<file src="bin\Bar.exe" target="bin" />
<file src="bin\Bar.pdb" target="bin" />
</files>
Unfortunately, TFS 2012 bulid server is not happy when running Octopack 3.0.23:
“Could not find a part of the path 'c:\buildwork\QAAgent\66\Sources\Foo\bin”
What is proper way to octopack include an exe build artifact in the project bin folder?
please advise
Hi - is your build output folder customized? If not, then you probably need to include \Release
in the src
path. Upon deployment you need to target the root folder being deployed, so I think target=""
will land these in the right place.
Hope this helps,
Nick
Nicholas, the output folder for the main project is plain old “bin” for all configurations. On my local VS2012 dev box this will build to “\Foo\bin”. Octopack runs without error when I build from command line on my local dev box. Problem is when we build on TFS build server it can’t find the exe that copied / created to outdir during post build event. On the TFS build server for whatever reason TFS splits everything into Sources and Binaries folders. On build server this will build to “\OctopusAgent\66\Binaries”. The Bar.exe is in the Binaries folder on the build server not the sources folder where the nuspec file is looking for it. What folder is the file “src” relative to in files xml? Can it accept MSBuild macros like $(TargetDir)? Note, I have the following msbuild props set for the build definition:
RunOctoPack and OctoPackPublishPackageToFileShare. I also added OctopackEnforceAddingFiles for good measure (do I need it?)
Can I somehow update the WrittenFiles for CreateOctoPackPackage to include my postbuild event created EXE?
Hi - sounds like you may need to do some MSBuild tweaking to get the sequencing you want.
In the CSPROJ file, before the OctoPack.targets file is imported, you might try inserting:
<Target Name="AfterBuild">
<Copy SourceFiles="$(OutputPath)\Foo.exe" DestinationFiles="$(OutputPath)\Bar.exe" />
</Target>
And remove the post-build step from your project.
MSBuild can get tricky unfortunately - if this doesn’t help you might try logging MSBuild verbose output. The goal is to get the OctoPack
target into the BuildDependsOn
list after the file copy’s done.
Another alternative that can quickly unblock these kinds of issues is to create a complete NUSPEC file and pack that using NuGet.exe pack
after the build is complete.
Let me know if this gets the wheels turning
Cheers,
Nick
Hi Nicholas, through trial and error I figured out that the files section in nuspec file is relative to the Sources folder on the TFS build server (not the Binaries folder). Since Octopack 3 no longer directly bundles output folder content, I modified main project and added a beforebuild target that adds our custom generated EXE to @FileWrites and Octopack 3 works great now (although it requires extra work that wasn’t required in Octopack 2.x).