fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
2.02k stars 523 forks source link

paket.targets per package #417

Closed ctaggart closed 8 years ago

ctaggart commented 9 years ago

When I adopted Paket, I was expecting paket.targets files per NuGet package to soon happen. It was mentioned before in #197. I'd really like to see this happen. Something like this:

<Import Project="..\..\..\packages\FSharp.Core\paket.targets" Condition="..\..\..\packages\FSharp.Core\paket.targets" />
<Import Project="..\..\..\packages\Newtonsoft.Json\paket.targets" Condition="..\..\..\packages\Newtonsoft.Json\paket.targets" />

There are way to many changes being made to the project files and this causes lots of noise in the diff and some frustration when merging. An example is this pull request I just made for FAKE: https://github.com/fsharp/FAKE/pull/602

forki commented 9 years ago

I know that this is a requested feature and I already started working on it. But it's not an easy one.

Regarding the FAKE changes. That's not that bad. The real issue was that I didn't make that Paket 0.17 transition before, so that you had both, the improved Paket output and your FSharp.Core changes in one Commit. But it's still good progress:

image

forki commented 9 years ago

sneak peek for v0.19:

image

isaacabraham commented 9 years ago

awesome

ctaggart commented 9 years ago

That is so beautiful!

You may wish to stick with lowercase paket.targets instead of Paket.targets since all the other files are lowercase. Since they are auto-generated, it doesn't matter much to me. May be that actually helps differentiate it from the other paket.targets used for msbuild targets.

panesofglass commented 9 years ago

Lovely! Does this mean packages need to publish paket.targets files?

ctaggart commented 9 years ago

No, they get generated by Paket when it unzips the nupkg.

forki commented 9 years ago

how about generated.paket.targets this will make it easy to find?

forki commented 9 years ago

There is still one issue left:

We can't create the targets files per package since we have to create different When clauses if the csproj file already contains the same framework assemblies.

So we have two options: 1) Create a targets file per package and project and put it under packages

What do you guys think?

/cc @agross @mexx

TWith2Sugars commented 9 years ago

I'd prefer option 1 with MyProject.paket.targets

forki commented 9 years ago

that wouldn't work since in one repository can be man MyProject.csproj files in different folders.

agross commented 9 years ago

If we go for option 1 we should regenerate the project structure and put the targets there.

agross commented 9 years ago
packages/Foo
packages/targets/src/Bar/Bar.csproj.paket.targets
src/Bar/Bar.csproj
src/Bar/paket.references
TWith2Sugars commented 9 years ago

how about to keep it all at the same level myproject.projectguid.paket.target?

agross commented 9 years ago

I'm against using GUIDs, they make it hard to reason about the relationship between ??proj and targets file.

TWith2Sugars commented 9 years ago

Not a new guid, the one that has been assigned to the *proj file.

agross commented 9 years ago

I think my argument still holds true ;-)

IMHO, GUIDs are for machines, not for human consumption.

TWith2Sugars commented 9 years ago

It's already in there and referenced by the .sln. This is just to make sure the target file is unique, if we keep the myproject on the front it should be easy to see which target file matches to the _proj. I don't think I've seen that many projects with the same name._proj.

TWith2Sugars commented 9 years ago

Fair enough :)

TWith2Sugars commented 9 years ago

Ah but aren't these target files mainly used for the machines ;)

forki commented 9 years ago

I vote for 2) ;-)

TWith2Sugars commented 9 years ago

@forki I'd be happy with either way, overall having .targets in regardless of where is still a huge benefit.

forki commented 9 years ago

I mean this still looks like good progress:

image

TWith2Sugars commented 9 years ago

nice

currently sitting here waiting for this to be merged to try it.

forki commented 9 years ago

you might want to test latest 0.19-alpha ;-)

already dogfooding: https://github.com/fsprojects/Paket/commit/99c038156c3df94022d1268f2b05a3a076923657

TWith2Sugars commented 9 years ago

@forki boom, works like a dream.

If everything is inside .paket.target then will you still need the true?

forki commented 9 years ago

If everything is inside .paket.target then will you still need the true?

the what?

TWith2Sugars commented 9 years ago

@forki updated previous comment

forki commented 9 years ago

ah very good point

forki commented 9 years ago

the question is: do we want to support the old mode where we don't create targets files. We could remove A LOT of code if not.

agross commented 9 years ago

I don't see a point in supporting two models. As long as we allow the user to edit targets files and include them in sourc control I think we're golden.

forki commented 9 years ago

"to edit targets files" - mmm. That would be defeating the whole point.

TWith2Sugars commented 9 years ago

I'd vote to support this mode (which people wanted for a while anyway) only.

agross commented 9 years ago

If only to temporarily fix a problem with some reference that's still covered by paket's reference logic. You know what I mean, tomorrow MS invents a new convention for the lib folder and we play whack-a-mole again.

agross commented 9 years ago

So it seems this doesn't work with Paket's own restore via paket.targets. Starting from a clean checkout (no paket.exe, no <project>.paket.targets) the process is as follows:

So it seems we either support auto-restore via paket.targets or we support <project>.paket.targets. You cannot have them both because this creates an ordering requirement that is, from my point of view, not satisfiable using MSBuild.

forki commented 9 years ago

omg

there seems to be no way to get VS restore working - and even the nuget guys don't do that anymore.

forki commented 9 years ago

Seems we have to discontinue automatic VS restore if we want target files. NuGet team came to the same conclusion: http://docs.nuget.org/docs/reference/package-restore

Instead we (as a comunity) could work on @hmemcpy's https://github.com/hmemcpy/Paket.VisualStudio and add restore to it.

TWith2Sugars commented 9 years ago

I personally never used pakets VS auto restore so it's something I wouldn't even notice if it went.

forki commented 9 years ago

I know that at least @ovatsus and @vasily-kirichenko think this is essential.

TWith2Sugars commented 9 years ago

Could this help? http://stackoverflow.com/questions/4919204/how-to-turn-off-caching-of-build-definitions-in-visual-studio

vasily-kirichenko commented 9 years ago

Yes, auto restore is essential. I cannot tell people that they must run something called Paket before they are able to build their solution.

forki commented 9 years ago

@twith2sugars how would that help?

It's really really sad. Instead of supporting PreSolutionBuild event in VS (which is already available in proper MSBuild) they built a nuget addin and shipped it in the VS box. This sucks big time.

Question is if a paket VS addin would be an acceptable solution.

ctaggart commented 9 years ago

To support the people who want to clone the project and build it from Visual Studio without touching the command line, a Paket Visual Studio extension would be an acceptable solution. This is similar to having the NUnit or xUnit extension in order to run unit tests from Visual Studio.

maartenba commented 9 years ago

@forki Nothing of interest in http://www.nuget.org/packages/NuGetEnablePackageRestore/ ? This used to be NuGet package restore long, long ago and worked from within VS.

ovatsus commented 9 years ago

Forcing to install a Paket extension in VS in order for your project to build is even worse than running the paket command line. Any open source .Net project should be able to just build by opening the sln. It's a real barrier to new users if they always have to go look at the readme to check what's the requirement for every specific project

agross commented 9 years ago

@Uli-Armbruster also wouldn't be pleased to learn that automatic restore in VS was discontinued.

forki commented 9 years ago

Ok I think there is no good solution to this. I propose the following:

This is far from perfect, but even for the autorestore people this might be a small benefit since they know they can nuke the targets file if a merge error occurs.

We will look for better solutions. Maybe we can talk to @JeffHandley and propose to open up the nuget addin.

What do you think?

TWith2Sugars commented 9 years ago

Sounds like a reasonable workaround

jeffhandley commented 9 years ago

As was pointed out, these problems are precisely why we ditched msbuild-integrated restore. Within VS, our extension hooks into the SolutionBuild event and executes restore BEFORE VS launches msbuild. Outside VS, it requires that build scripts run nuget.exe restore. That achieved the results that we wanted: no-touch restore in VS, but very scriptable outside VS. It's worked out great.

forki commented 9 years ago

@JeffHandley we know that. The only issue for paket is: we are not in the Visual Studio box and I don't see a good chance to get in. On Dec 10, 2014 9:25 PM, "Jeff Handley" notifications@github.com wrote:

As was pointed out, these problems are precisely why we ditched msbuild-integrated restore. Within VS, our extension hooks into the SolutionBuild event and executes restore BEFORE VS launches msbuild. Outside VS, it requires that build scripts run nuget.exe restore. That achieved the results that we wanted: no-touch restore in VS, but very scriptable outside VS. It's worked out great.

— Reply to this email directly or view it on GitHub https://github.com/fsprojects/Paket/issues/417#issuecomment-66517859.

isaacabraham commented 9 years ago

@ovatsus why is an extension such a bad thing? there's a plug-in for nuget, there could (should?) be one for paket as well. In addition to doing the Nuget-esque pre-build steps, it could do other things as well such as integrated ability to modify paket via a GUI integrated into VS rather than having to fall back to the command line (or fsx).