Skip to content
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

Bootstrapper magic mode & run #1961

Merged
merged 19 commits into from
Oct 22, 2016
Merged

Bootstrapper magic mode & run #1961

merged 19 commits into from
Oct 22, 2016

Conversation

vbfox
Copy link
Contributor

@vbfox vbfox commented Oct 12, 2016

Bootstraper Magic mode (And also --run but that's boring)

It add 2 features to the bootstraper:

  • --run when passed all arguments after it are ignored and when paket.exe is downloaded it's started with the remaining arguments
  • Magic mode similar to some unix binaries that change behavior when renamed, the bootstraper when renamed to paket.exe behave just like it !
    • Download the real file to the temp directory and assume --run
    • Except if --run is really passed, pass all it's arguments to paket.exe as-is
    • Keep using the same file without checking for updates for 12 hours (Assume --max-file-age=720)

The end result is that the bootstraper paket.exe can be placed at the root of a repository avoiding the need of shell scripts, cmd scripts or even a .paket folder.

The "first time user" experience is also much better : place paket.exe in solution root then paket init. You can commit it, it's small and keep itself up-to-date.

PS: The bootstraper gain 4KB moving from 39KB to 43KB

vbfox added 9 commits October 12, 2016 23:31
When this parameter is present the boostraper run paket.exe after
downloading it. It also ignore all parameters after --run and pass them
back to paket.exe
If the bootstraper is renamed to paket.exe it download the real paket.exe
to the temporary folder instead.

In addition if --run isn't specified on the command line it act as if it
was passed and run paket.exe with all the arguments it received.

The result is that it produce a paket.exe of 47Ko that act like the normal
one (As long as an internet connection is available)
* As Process.Start isn't powerful enough to support our scenario PInvoke
  is used on both windows and unix to get the functionality of running a
  subprocess while keeping the console.
* The bootstraper now get an icon, only a low resolution one but it look a
  little nicer.
Sad but 6KB on a 48KB executable is too much for an icon
@vbfox vbfox changed the title [WIP] Bootstraper run Bootstraper run Oct 14, 2016
@vbfox vbfox changed the title Bootstraper run Bootstraper magic mode & run Oct 14, 2016
@vbfox vbfox changed the title Bootstraper magic mode & run [WIP] Bootstraper magic mode & run Oct 14, 2016
@vbfox
Copy link
Contributor Author

vbfox commented Oct 14, 2016

Still WIP as the console ends up slightly corrupted on MacOSX, don't know if it's fixable.

vbfox added 2 commits October 15, 2016 01:58
The code is tested on "Ubuntu on Windows" and i'll validate it also on MacOSX Sierra.
@vbfox vbfox changed the title [WIP] Bootstraper magic mode & run Bootstraper magic mode & run Oct 15, 2016
@vbfox
Copy link
Contributor Author

vbfox commented Oct 15, 2016

I think this PR is ready for being tested/checked @forki . It should be labeled as "alpha" or something like that until it's tested on more platforms / by more people.

I had some problems on mono/unix but I think they are now solved with the latest commit working without problems on the systems I have access to. If anyone is interested in the murky little details UnixMonoConsoleRunner.cs contains a bunch of comments.

Tested on:

  • Windows 10
  • Bash on Ubuntu On Windows
  • MacOSX sierra

@baronfel
Copy link
Contributor

Oh nice, lemme give this a spin on my own and windows boxen

@baronfel
Copy link
Contributor

With the PR should we also update the paket.targets to use the new paket.exe convention? The paket.targets that get pulled in on init now also pull in another copy of the bootstrapper, which is redundant if the user has paket.bootstrapper.exe renamed in their solution/project root.

@vbfox
Copy link
Contributor Author

vbfox commented Oct 15, 2016

@baronfel Ah yes I forgot about that feature :)

A lot of things can be solved with the main executable knowing (via an argument) that it was started from a bootstraper already. I'll add that to the PR.

vbfox added a commit to vbfox/ColoredPrintf that referenced this pull request Oct 19, 2016
vbfox added a commit to vbfox/MasterOfFoo that referenced this pull request Oct 19, 2016
@forki
Copy link
Member

forki commented Oct 20, 2016

Do you think it's ready for alpha release? Can you please add a bit of docs?

@vbfox
Copy link
Contributor Author

vbfox commented Oct 20, 2016

Yes I think it's ready. When merged the version in PaketRunner might need adjustment but that's all.

Regarding docs I documented it in the doc about bootstraper.
To avoid confusing users while it's still in test I didn't change the installation / getting started pages. Should I change them ? Maybe only installation with a warning that it's experimental ?

@forki forki merged commit c2e92ca into fsprojects:master Oct 22, 2016
@forki
Copy link
Member

forki commented Oct 22, 2016

thx I released it in alpha!

@forki
Copy link
Member

forki commented Oct 22, 2016

can we get alpha versions of paket in magic mode?

@vbfox
Copy link
Contributor Author

vbfox commented Oct 22, 2016

can we get alpha versions of paket in magic mode?

Yes you can but can't ask for "prerelease" in general you must specify a version for now. Even in magic mode the .config file is still supported for that, creating a paket.exe.config with :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="PaketVersion" value="3.24.0-alpha002"/>
  </appSettings>
</configuration>

Will use the current alpha.

If the magic mode is really useful and used a lot I was thinking to move paket version specification in paket.dependencies using a very simple syntax known to the boostraper and that the main executable ignores like :

# bootstraper: 3.24 --prefer-nuget

source https://api.nuget.org/v3/index.json
nuget FAKE
nuget FSharp.Core ~> 4

@forki
Copy link
Member

forki commented Oct 24, 2016

yes that would be awesome

@forki
Copy link
Member

forki commented Oct 24, 2016

what I would need right now is a setting in appsettings that will take latest alpha

@vbfox vbfox changed the title Bootstraper magic mode & run Bootstrapper magic mode & run Oct 24, 2016
@vbfox vbfox mentioned this pull request Oct 24, 2016
forki added a commit that referenced this pull request Oct 25, 2016
@pmiossec
Copy link

The end result is that the bootstraper paket.exe can be placed at the root of a repository avoiding the need of shell scripts, cmd scripts or even a .paket folder.

The "first time user" experience is also much better : place paket.exe in solution root then paket init. You can commit it, it's small and keep itself up-to-date.

Is it the recommended way to use it? Or is it advised to keep the bootstrapper, once renamed, in the .paket folder?
Because in this case the paket.targets does not work anymore :(

Or perhaps update the lines at the beginning of paket.targets file :

<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)..\paket.exe</PaketExePath>
<PaketExePath Condition="!Exists('$(PaketExePath)')">$(PaketToolsPath)paket.exe</PaketExePath>

to verify if we use it as "magic mode" otherwise, continue as usual... (solution tested and that seems to work)

@vbfox
Copy link
Contributor Author

vbfox commented Oct 25, 2016

@pmiossec for now i'd recommend to keep it in .paket for compatibility.

Thanks for the .targets fix :)

As I like having paket.exe in the root i'll continue to fix small details in this mode but I don't know if it'll ever be the recommended / default way 😸 (Magic mode itself might become the recommended / default in v4)

vbfox added a commit to vbfox/Paket that referenced this pull request Oct 26, 2016
It's now possible to do that with the magic mode and as disussed in fsprojects#1961 the targets file should support it
vbfox added a commit to vbfox/Paket that referenced this pull request Oct 27, 2016
It's now possible to do that with the magic mode and as disussed in fsprojects#1961 the targets file should support it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants