Skip to content

[wip] dotnet cli restore: read IntermediateOutputPath - #2642

Closed
0x53A wants to merge 16 commits into
fsprojects:masterfrom
0x53A:explicit-immediate-path
Closed

0x53A wants to merge 16 commits into
fsprojects:masterfrom
0x53A:explicit-immediate-path

Conversation

@0x53A

@0x53A 0x53A commented Aug 20, 2017 •

Copy link
Copy Markdown
Contributor

You can redirect where nuget and the cli do their stuff, but paket currently ignores that.

This adds two more parameters: one for where the references file should be written and one for the intermediate dir.

The second one is required so paket knows where to copy the nuget.config.

The first one is not yet required - it could just write it to the intermediate directory.

But for #2606 we will need more than one file (one per configuration/tfm) so I added an explicit parameter now.

let scenario = "i00xxxx-obj-dir"
let tmpPaketFolder = (scenarioTempPath scenario) @@ "../.paket"
let targetsFile = FullName(__SOURCE_DIRECTORY__ + "../../../src/Paket/embedded/Paket.Restore.targets")
let paketExe = FullName(__SOURCE_DIRECTORY__ + "../../../.paket/paket.exe")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong (and is also wrong in the test above): it copies the checked-in version of paket, not the previously build one.

Tomorrow ...

@matthid matthid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some stuff i noticed not a full review :)

let paketExe = FullName(__SOURCE_DIRECTORY__ + "../../../bin/paket.exe")

setEnvironVar "PaketExePath" paketExe
prepare scenario

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we now have a new prepareSdk function to simplify these tests :)

Comment thread src/Paket/Paket.fsproj
<StartArguments>update</StartArguments>
<StartWorkingDirectory>C:\proj\testing\testpaketfailure\</StartWorkingDirectory>
<StartArguments>fix-nuspecs files src/Paket.Core.preview3/obj/Paket.Core.1.0.0.nuspec project-file src/Paket.Core.preview3/Paket.Core.fsproj</StartArguments>
<StartWorkingDirectory>C:\proj\Paket</StartWorkingDirectory>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do this myself all the time. I don't know why vs is failing so hard here.

Ideally we would gitignore that section of this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah ... please remind me again after I remove the wip

|> Seq.filter (fun proj -> proj.GetToolsVersion() >= 15.0)
|> Seq.iter (fun proj ->
RestoreNewSdkProject dependenciesFile lockFile resolved groups proj
let objDir = objDir |> Option.defaultValue (Path.Combine(Path.GetDirectoryName(proj.FileName),"obj"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this path is called if I just do "paket restore"? Then we would need to crack the project file and manually parse "$(BaseIntermediateOutputPath)". :\

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

@matthid Your performance improvements have made this a little bit harder :\

Before, paket was called each time directly from msbuild, so it was easy to just pass-through any MSBuild variables.

As I understand it now, you now do an "external" restore, which is not triggered by msbuild.

So I have no idea how to pass the MSBuild variables, because I really don't want to crack open and parse the project file manually.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

@0x53A

As I understand it now, you now do an "external" restore, which is not triggered by msbuild.

It is triggered on demand:

  • we will do a full restore when we detect that the last restore is not up to date (paket-files)
  • we will do a partial restore when we detect that the project file has changed

If nothing is outdated we will skip calling paket and will just read and forward the files in the obj/ directory.

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

If I run "paket restore", then run "dotnet restore", which of the two will write the obj\paket.referenced files?

My understanding (which may be totally wrong) is:

  • previously: "paket restore" only restored the packages directory, "dotnet restore" called paket once for each TFM.
  • now: "paket restore" will generate all files, "dotnet restore" afterwards is a nop and would only do something if the project file was changed.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

@0x53A Yes both is correct. But if you do NOT call paket restore and ONLY dotnet restore it will do a paket restore as well (but only a single time for ALL projects / TFMs)

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

And that is precisely my issue: I need to pass through one variable from inside the project file, which I can't, because the restore is "external".

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

Why? From Paket's world view restore is a global operation. I also pass properties (namely the target framework list for example...)

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

How do you read the TFM list? What if it was not set directly in the project file, but in a directories.props?

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

Basically this seems like a repetition of #2241, which also failed if the property was not set directly in the project file, but in an imported target/props.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

@0x53A That is not working sadly, because currently I used the paket internal project framework parser.
Mid-Long term we need to switch to what @enricosada is doing via https://github.com/enricosada/dotnet-proj-info which works but is slow.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

Basically this seems like a repetition of #2241, which also failed if the property was not set directly in the project file, but in an imported target/props.

Correct. Same problem and same code...

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

Alternatively we make paket fast enough to always call it in msbuild. But currently when we do it paket starts to become unusable if you try to use it in a solution with more than 7 projects (at least IMHO).

@0x53A

0x53A commented Sep 17, 2017 •

Copy link
Copy Markdown
Contributor Author

Alternatively we make paket fast enough to always call it in msbuild.

I fear that is the only reliable solution. We can still do an up-to-date check, but the first creation needs to be from inside the project (once for each TFM) so we don't need to parse the msbuild file from "outside" and instead can just read the in-memory variables.

Assuming (I haven't profiled it yet) that a non-neglible part is JIT, we should guide users to NGEN paket.exe.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

Assuming (I haven't profiled it yet) that a non-neglible part is JIT, we should guide users to NGEN paket.exe.

I don't think that will be enough. Also we should probably find an automatic solution. Always calling NGEN manually after updates is not really a viable option oO

@0x53A

0x53A commented Sep 17, 2017 •

Copy link
Copy Markdown
Contributor Author

The best option would be AOT, and then the bootstrapper can detect the system platform and download the specific version.

ngen requires admin permissions, so unless the user runs us from an admin shell, we can't do it ourselves.

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

I should have finished this earlier and added an integration test, then you would have had to deal with his :\

Sorry, I am just slightly unhappy at the moment.

@matthid

matthid commented Sep 17, 2017

Copy link
Copy Markdown
Member

I'm sorry, on my defense I told you somewhere (issue or other PR that I planned to change this).

@0x53A

0x53A commented Sep 17, 2017

Copy link
Copy Markdown
Contributor Author

Ok.

so my first step would be to use the current parser (even with its known issues) to read BaseIntermediateOutputPath, and then at an unspecified date later maybe try to fix the issues for real without regressing the performance too much.

@theimowski

Copy link
Copy Markdown
Member

Has this been abandoned as of now? I'd have some interest in this feature as well

@theimowski

Copy link
Copy Markdown
Member

bump up @matthid @0x53A I know it's been a while since you last commented on this, however I'd like to know if anything changed in this regards and it's possible to add support for IntermediateOutputPath? Or are we still blocked by the same issues?
I'm happy to help with this feature if necessary

@0x53A

0x53A commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

The issue back then was that paket did one external restore for all frameworks. It would need to do restores when called from MsBuild so it has proper access to the MsBuild variables.

I do not know if anything changed in that regard.

@0x53A

0x53A commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

And in the forseable future I don't have much time, so I'll close this PR, sorry.

If you want to work on it, then I guess the strategy would be the same - pass IntermediateOutputPath from Paket.Restore.targets to paket.exe, then route it through.

@0x53A 0x53A closed this Mar 8, 2019
@theimowski

Copy link
Copy Markdown
Member

Thanks @0x53A I'll give it a go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants