OctoPack is skipping vital files

Hi,

I am working with TeamCity & Octopus Deploy to kick off CI/CD for a SharePoint project. I am unable to get OctoPack to add the .wsp file(s) to my solution during the builds process in TeamCity. Since, OctoPack skips the file(s) the deployment to SharePoint files due to not having .wsp file(s) in the directory of the unpacked project. I have tried to add a nuspec file allowing the addition of missing files, but the process will just skip my configured directories in my nuspec file.

nuspec file config: Attempted Configuration

<files>
   <file src="bin\*.*" target="bin" />
 </files>
<files>
   <file src="bin\Debug\LITTLER.Branding.wsp" target="LITTLER.Branding.wsp" />
 </files>
<files>
   <file src="bin\*\*.*" target="" />
 </files>
<files>
   <file src="bin\*" target="" />
 </files>

Command Line Parameters:

/t:Build /p:IsPackaging=True /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=true

The process definitely finds my nuspec file and updates the file through out the process all while being skipping “bin*.*” configuration. I would expect to find more files using the command line switch “/p:OctoPackEnforceAddingFiles=true” and a custom nuspec file, but this is not working. Any thoughts or suggestions would be greatly appreciated.

Hi Zach, thanks for getting in touch,

Unfortunately OctoPack only understands specific project types, which may explain why you are running into this issue. The Octo.exe pack command may be a viable alternative. The only real requirement for its use is the possibility of publishing the application to the local file system, which Sharepoint does seem to support.

You would be able to use octo in this scenario to create the package by using the pack command i.e.:

octo.exe pack --id=package.name ----format=nuget --version=sem.ver --outFolder=output.path --basePath=published.folder

We also have the Team City Plugin which uses octo.exe under the covers that makes this somewhat easier when used as part of a TeamCity build. We also had a great blog some time ago on setting up these builds for .NET Core and although commands and build is somewhat different, it may still prove to be useful.

Please let me know if that helps,

Regards,
Shaun

Hey @Shaun_Marx,

We are using the TeamCity plugin and experiencing the same issue. From my end as a user, this looks to be a potential bug related to how the switch ‘/p:OctoPackEnforceAddingFiles=true’ for adding the rest of the debug folder. As a workaround, we have to use the push command with a custom created zip package that is sent to Octopus Deploy from TeamCity.

Thank you for the link, I have actually seen this before and to be honest, is not very helpful in relation to this issue at hand. The documentation is really limited and does not show real world example of this switch command nor a definition on what it does. Could you kindly provide an real world working example of this switch “/p:OctoPackEnforceAddingFiles=true” working to add the rest of the debug folder from the build?

Documentation for Command

By default, when your NuSpec file has a <files> element, OctoPack won’t automatically add any of the other files that it would usually add to the package. Set this parameter to true to force OctoPack to add all the files it would normally add.

Personally, the above documentation reads that ‘files’ nuspec config should be ignored and add only what is defined, but this appears to be being ignored either with or without this setting. Octopack.exe running in TeamCity via the plugin appears to completely ignore this command switch (OctoPackEnforceAddingFiles).

For example, do I need to update my csproj files as well and enforce this command? I have seen this suggested in the past on this forum.

Thanks.
Zach

Hi Zach,

I apologize that did not give you the answer you were looking for. We don’t give OctoPack much love these days due to the general direction of .NET and recommend Octo.exe for most scenarios. That being said if your project file is called Test.csproj and you have Test.nuspec as a sibling, then you should be able to add additional files in the following manner:

<?xml version="1.0"?>
<package >
  <metadata>
    ...
  </metadata>
   <files>
    <file src="**\*.wsp" />
    <file src="../ContentThatsNotIncludedAsBuildOutput/*.test" />
  </files>
</package> 

You should then be able to run msbuild from the solution root:

msbuild YourSolution.sln /t:Build /p:Configuration=Release /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=true /fl

Generally anything that ends up in the output folder as part of the build should be included, but if you have included additional files as per the example above, you will need to use the /p:OctoPackEnforceAddingFiles=true. The reason for this, is that Octopack knows about certain project types and usually infers what content to include based on that. Without this flag the usual content won’t be included and at worst will fail to build. I tested this with a project locally and indeed appears to be the case.

For example, do I need to update my csproj files as well and enforce this command? I have seen this suggested in the past on this forum.

I am unaware of any changes that you would need to make to the project file for this to work. It may however be needed in some instances if you need something specific from msbuild. Do you possibly have the links to the topics?

You mentioned previously that the build in TeamCity seems to be ignoring the /p:OctoPackEnforceAddingFiles=true parameter, does this mean that you are able to get the correct output when running msbuild locally? If so, we may need to get a bit more information regarding your build in TeamCity as well as any relevant build logs which can help us.

Regards,
Shaun

@Shaun_Marx,

Thank you for the details this got it working for us! I really do super appreciate the help and details provided, hopefully this helps others as well! Lastly, I was unable to find the link stating a csproj file update as a test.

Cheers.
Zach

1 Like

Hi Zach, no problem at all,

Glad to hear you managed to get it working. If you do however run into any additional issues, please don’t hesitate to let us know.

Happy deployments!

Regards,
Shaun

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.