I have to use
/p:DeployOnBuild=true /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=True with MSBuild.
I understand Nuget and how to exclude files via a nuspec.xml e.g.
<files> <file src="*\**" target="\" exclude="MyFolderToExlude\**\*.js"/> </files>
This exclusion is in the projects’ Nuspec file already, The problem Is that
p:OctoPackEnforceAddingFiles=True initially includes all these files in package , and the only use that he nuspec files is to actually add files to the build which
p:OctoPackEnforceAddingFiles did not pick up - it can’t retrospectively go and delete files from the packages.
I also tried to Delete these files as a build step before the MSBuild event, but the build then fails
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(2567,5): error : Copying file MyFolderToExlude\ThisFileShouldntBeIncluded.js to obj\Release\Package\PackageTmp\MyFolderToExlude\ThisFileShouldntBeIncluded.js failed. Could not find file 'MyFolderToExlude\ThisFileShouldntBeIncluded.js'. [<path>\MyProject.csproj]
How do I get to use
p:OctoPackEnforceAddingFiles and exclude specific files, before the file gets packaged?
Unfortunately the only way you would probably be able to exclude files that are being collected up automatically by Octo.exe would be to disable the
p:OctoPackEnforceAddingFiles flag and explicitly include/exclude the files you want via the nuspec
Let me know if you need any further clarification,
Hi Rob, the effect of this is massive. It is something that Octo should consider looking at - the p:OctoPackEnforceAddingFiles flag is indispensable. Without it like you say, one should explicitly include files - this is not even an option - Octo improves my process by doing this for me.
Yet now I can’t use the Deploy to IIS option - which is best thing ever , because of the fact that there are files in the nupkg that I can’t get rid of.
Now I need to deploy to a folder, manually delete those files, then I can’t deploy to IIS anymore. I now need to manually set up a site and just push files to folders.
Unfortunately at the moment we have no plans to add any additional flags as we believe the existing features seem to meet most other user’s scenarios and is not something that has come up before.
I notice that you added this as a UserVoice suggestion and that is the best way for us to gauge if it really is something that there is a high demand from individual users so thank you for adding that request.
Is there any reason you cant leverage the existing pre-deploy scripts to remove the files that you don’t want? This should occur before any IIS or further deployment steps take place.
Hi Rob, I did not know of the pre-deploy scripts and i 'm looking at it now.
How do I get the path to the extracted folder? Im looking for a variable that I can use in powershell because its not a constant folder name e.g.
Looks like this is what I need to do
$packageDir = $OctopusParameters[“Octopus.Action[MyApp].Output.Package.InstallationDirectoryPath”]
Looking at the docs I believe that the variable you are after is
Octopus.Action.Package.InstallationDirectoryPath. What you can also do to help debug these system variables, is to include a project variable
OctopusPrintVariables and set its value to
True. The step will then echo out all the variables into the logs so that you can ensure the right value is used.
Let me know if you run into any further issues.
Looks like you beat me to it
Perfect solution , thank you Rob, please close ticket