New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude package versions from tool package folders #1410
Exclude package versions from tool package folders #1410
Conversation
tools/run-csx.cmd
Outdated
@@ -26,10 +26,10 @@ if not exist %TOOLS_DIR%\.nuget md %TOOLS_DIR%\.nuget | |||
copy /Y %NUGET_CACHE_DIR%\NuGet.exe %TOOLS_DIR%\.nuget\NuGet.exe > nul | |||
|
|||
rem restore packages for build script | |||
%TOOLS_DIR%\.nuget\NuGet.exe restore %TOOLS_DIR%\packages.config -PackagesDirectory %TOOLS_DIR%\packages -Verbosity quiet | |||
%TOOLS_DIR%\.nuget\NuGet.exe install %TOOLS_DIR%\packages.config -OutputDirectory %TOOLS_DIR%\packages -Verbosity quiet -ExcludeVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nuget install
on a packages.config basically does the same thing as nuget restore
, but has the -ExcludeVersion
switch
Actually I just realized something... If we update the version in packages.config, NuGet won't know that the currently installed version isn't the right one, so it won't reinstall it. I have an idea to work around this, stay tuned. |
855c106
to
fc15b04
Compare
I see a failing build that is not your fault: https://ci.appveyor.com/project/FakeItEasy/fakeiteasy/build/633-cyahcldk#L342
The actual count was 2. I suspect this is a race condition, which you predicted, @thomaslevesque. I'll investigate as time allows. |
Here's my idea:
(it's the approach used by Cake) What do you think? |
That sounds pretty good, @thomaslevesque. |
Would you mind if I converted run-csx.cmd to PowerShell? PowerShell (4+) has a |
All done, tell me what you think! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, @thomaslevesque.
I was going to suggest a more granular approach to deleting the old packages, but they're probably just sitting in the NuGet cache anyhow, so I think this is the right approach.
I did make some minor comments, but would not hold up the merge for them, nor for this one:
now that we have PowerShell, I notice the various comments in the file and in some cases think that the blocks of functionality could easily be extracted into their own functions, as part of my motto "if it's worth commenting, it could be a function". Do you think there's value in that? If not, say the word, update the title (to not be WIP) and I'll merge.
tools/run-csx.ps1
Outdated
& $NuGetExe install $PackagesConfig -OutputDirectory $PackagesDir -Verbosity quiet -ExcludeVersion | ||
|
||
# run build script | ||
$CsiExe = "$ToolsDir\packages\Microsoft.Net.Compilers\tools\csi.exe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a small thing, but $PackagesDir
instead of $ToolsDir\package
?
tools/run-csx.ps1
Outdated
$PackagesHash = (Get-FileHash -Algorithm SHA1 -Path $PackagesConfig).Hash | ||
# if packages.config has changed, clear packages and store new hash | ||
if ($PackagesHash -ne $PreviousPackagesHash) { | ||
Write-Host "Packages.config has changed, reinstalling packages..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider $PackagesConfig
instead of "Packages.config", unless you want to hide the path (which is fine)
Sure, I'll do it |
Push-Location $RepoRoot | ||
|
||
DownloadNuGetToCache | ||
CopyNuGetLocally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume there's a good reason for copying nuget in a local folder, but I don't remember what it is... Why don't we use it directly from the cache directory? Or why don't we download it directly to the local directory?
I think the local directory could act as the cache; a build script has no business writing to the user's AppData folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I stumble over this as well. I think @adamralph originated the behaviour or imported from somewhere else.
I wouldn't mind if either the caching or the copying went away (I don't mind the build script writing to the AppData folder, but don't mind it not doing it either).
The current system does give a way to always have the correct nuget in the local directory (because the cache directory is versioned) without downloading it all the time or having the rest of the build system need to know what the version is.
I guess it also allows one to switch between (already cached) versions while disconnected. but that's a small concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't even mind the idea of committing the nuget exe, if we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might find it simpler to do away with scripting completely, as I've done with xbehave and @blairconrad has done with SelfInitializingFakes. It allows you to drop nuget.exe, csi.exe, packages.config, etc. All you need is a csproj for package references and a Program.Main for your build "script". You can then invoke simply with dotnet run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it might make things easier...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, a mixed VB/C# solution isn't a use-case either, since an analyzer is installed in a project, which can't be mixed language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but the meta-package does provide a convenient way to update both C# and VB versions at once. For me, it's not enough of an advantage to continue with it, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to use dotnet script
instead of manually invoking csi.exe. It natively supports NuGet references. It requires .NET Core SDK 2.1+, though, since it's a global tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotnet script
also requires bootstrapping, or listing as another pre-requisite. The beauty of the dotnet run
approach is that nothing else is required other than the dotnet SDK, which is already a pre-requisite.
Also, you get full tooling support, in all IDEs, since it's just a regular C# project. No special scripting plug-ins, etc. required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point!
5f9b233
to
dc6ab49
Compare
dc6ab49
to
b50be05
Compare
@thomaslevesque, thanks for the changes. It looks great. I'm happy to merge after squash. And continue to explore the "cached and copied nuget" either here or elsewhere. |
👍 |
b50be05
to
e4b5235
Compare
Nice job, @thomaslevesque. Thanks. |
Thanks for the merge, and the comments! |
#r "packages/Bullseye.1.1.0-rc.2/lib/netstandard2.0/Bullseye.dll" | ||
#r "packages/SimpleExec.2.2.0/lib/netstandard2.0/SimpleExec.dll" | ||
#r "packages/Bullseye/lib/netstandard2.0/Bullseye.dll" | ||
#r "packages/SimpleExec/lib/netstandard1.3/SimpleExec.dll" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FakeItEasy/owners was the change back to netstandard1.3
intentional? The restoration graph is much lighter if you use netstandard2.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamralph no, it's not intentional. I must have done it when I resolved a conflict with #1409
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. That had caught my eye initially and I forgot about it in the other conversation (none of which was as important as that).
This change has been released as part of FakeItEasy 4.8.1. |
1 similar comment
This change has been released as part of FakeItEasy 4.8.1. |
Just an idea, feel free to close if you don't like it...
This will make updates easier as we won't have to update the paths in csx scripts.
Small gotcha: you have to remove the packages already installed first. Even with(solved by checking if packages.config's SHA1 has changed since last run)-ExcludeVersion
,nuget install
won't reinstall package Foo 1.0.0 if it already exists in folderFoo.1.0.0
(which feels like a bug to me)