Open flcdrg opened 8 years ago
@flcdrg agreed! I see you are working on a PR for this.
Let us know when you have something that you would like us to review. Ideally, this PR would cover the build.sh file as well 😄 but understand if that isn't possible.
Yeah. My bash skills are very rusty but I'll see if I can do something.
Sent from my Windows Phone
From: Gary Ewan Parkmailto:notifications@github.com Sent: ‎13/‎10/‎2016 5:11 PM To: cake-build/resourcesmailto:resources@noreply.github.com Cc: David Gardinermailto:david@gardiner.net.au; Mentionmailto:mention@noreply.github.com Subject: Re: [cake-build/resources] Build.ps1 doesn't play nice with an existing 'tools' directory (#15)
@flcdrg agreed! I see you are working on a PR for this.
Let us know when you have something that you would like us to review. Ideally, this PR would cover the build.sh file as well 😄 but understand if that isn't possible.
You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/cake-build/resources/issues/15#issuecomment-253427610
I have found that this deleting of content under /tools
becomes more of an issue under PowerShell 3 ..
I added the newly launched Cake.BuildSystems.Module to my build this morning using the updated bootstrapping script and the /tools/modules/packages.config
way of loading modules.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake.LongPath.Module" version="0.3.0" />
<package id="Cake.BuildSystems.Module" version="0.1.0" />
</packages>
I had previously been downloading/installing the Cake.LongPath.Module through the build.ps1 file itself; this is not directly related to the inclusion of Cake.BuildSystems.Module!
Upon triggering a TeamCity build, I immediately found that neither of the modules were being loaded.
Further inspection of the working directory on the agent showed that the /tools/modules
folder was completely gone. I worked backward to isolate it to the line at Remove-Item * -Recurse -Exclude packages.config,nuget.exe
Comparing the Build agent against my local environment (PowerShell4), I found that the agent was PowerShell 3
PS C:\Users\kcamp> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
Updating the agent isn't in the cards at the moment, I wound up modifying the bootstrap file to a workable analog. Sharing this bit of script mostly for record if anyone else runs into this. I don't know if there's a strong need or desire to support PowerShell 3 out of the box, but if this can help someone, great.
# First, get all file that aren't packages.config or nuget.exe, delete them.
Get-ChildItem *.* -Recurse | Where { $_.Name -ne 'packages.config' -and $_.Name -ne 'nuget.exe' } | Remove-Item -Force -Recurse
# Now make a second pass just to remove the folders that might be still there and empty.
Get-ChildItem * -Recurse | Where { $_.PSIsContainer -and $_.GetFiles().Count -eq 0 } | Remove-Item -Force -Recurse
Got hit by this today. Not only did build.ps1 delete all my existing tools, it also failed to bootstrap itself.
FYI I've been using the changes from https://github.com/cake-build/resources/pull/17 with success locally.
I think the feedback on the PR was that it possibly wouldn't be accepted just because it's a sizable change.
Maybe an alternative would be to do a better job of sniffing the tools
directory to decide whether it looks like it has Cake things in it or not. If it doesn't then be a bit more conservative about not just blowing it away.
I had the same problem with the modules folder. With the current version of bootstrapper the following lines bring me to the solution:
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
Remove-Item -Recurse
}
As soon as I versioned the packages.config.md5sum
file too, the problem is gone away. Without versioning this file, modules folder is deleted on CI systems (like GitLab, Jenkins or TeamCity).
If a
tools
directory already exists, then the currentbuild.ps1
appears to want to delete all the contents. This is not very neighbourly of it (especially as it isn't that unusual for a solution to have a tools directory).Ideally, build.ps1 should: