Repository navigation
Implement excluding <PrivateAssets>All</> dependencies during publish. - #212
Conversation
This is the equivalent of 'type: build' dependencies in project.json. Fix #42
3b609fe to
7c9e63d
Compare
| @@ -0,0 +1,173 @@ | |||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | |||
There was a problem hiding this comment.
This is not a brand new file, it was renamed from LockFileTargetExtensions to LockFileExtensions, since there are more than just LockFileTarget extensions in here.
If you want to view the diff, pull the branch locally and use VS Team Explorer. It shows the file as renamed, and only shows the changed code.
…jects. Fixing a bug in the GetPrivateAssetsExclusionList method when using P2P references. Need to resolve P2P references from the lock file by matching the projectFileDependency value with the Library's msbuildProject path.
| Path.GetDirectoryName(_projectPath), | ||
| library.MSBuildProject)); | ||
|
|
||
| if (string.Equals(fullDependencyProjectPath, projectFileDependencyName, StringComparison.Ordinal)) |
There was a problem hiding this comment.
If not, this line is equivalent to the more succinct if (fullDependencyProjectPath == projectFileDependencyName)
There was a problem hiding this comment.
@emgarten ? Will these paths always be in the same case?
My thought is we should be case-sensitive since we support case-sensitive file systems. And if these really should be case-sensitive, I'll change to the more succinct code.
There was a problem hiding this comment.
It should be the same case, but that depends on MSBuild returning the same absolute path casing as Path.GetFullPath. There is probably a scenario where they will not match up, but for case-sensitive file systems you would need it.
NuGet should be using the library name all over instead since that is unique. I've opened a bug to track that work: NuGet/Home#3611
As a workaround for now you could detect if the name has a forward or back slash and then continue this path lookup, otherwise it's just the library name.
| IDictionary<string, LockFileTargetLibrary> libraryLookup) | ||
| { | ||
| // TODO: exclude "type: build" dependencies during publish - https://github.com/dotnet/sdk/issues/42 | ||
| var nonPrivateAssets = new HashSet<string>(); |
There was a problem hiding this comment.
Similar question, all of these tables are case-sensitive by design, right?
There was a problem hiding this comment.
Oh, these are case-insensitive actually, since the strings are NuGet package Ids - which are case insensitive. I'll fix these up.
|
|
||
| ProjectContext projectContext = lockFileTarget.CreateProjectContext(); | ||
| _privateAssetPackageIds = privateAssetPackageIds; | ||
| return this; |
There was a problem hiding this comment.
WithXxx pattern is used extensively in immutable designs (e.g. basically all of Roslyn) to mean create a new instance with Xxx. Modifying current instance and returning this in a "wither" is very surprising to me.
There was a problem hiding this comment.
This pattern is used extensively in the CLI (and NuGet and ASP.NET [same authors]):
An example from each repo:
https://github.com/dotnet/cli/blob/1278e9d6bf35500e9672fe3f53125df1d08717d8/src/Microsoft.DotNet.ProjectModel/ProjectContextBuilder.cs#L78-L148
Not saying it makes it "right", but I don't think it has to be immutable, just "fluent".
There was a problem hiding this comment.
cc @terrajobst. Irrespective of fluency, 'with' is an especially bad naming choice for something that has a side-effect IMHO.
There was a problem hiding this comment.
x.WithY(y) changing x is really unfortunate.
There was a problem hiding this comment.
I'm not really inventing a new pattern here. :
https://en.wikipedia.org/wiki/Fluent_interface#C.23
http://stefanoricciardi.com/2010/04/14/a-fluent-builder-in-c/
Here's the same pattern in the corefx repo:
We can change the word "With" to something else, if you feel that strongly. But this pattern is more common than just my usage. This is how you build fluent interfaces without creating a bunch of little, throw-away objects.
There was a problem hiding this comment.
Don't bother. I give up. 😢
There was a problem hiding this comment.
The clear precedent across these projects is a fair reason to stick with it here. It's a mind bender for me that such a pervasive pattern in Roslyn is not universal in the ecosystem, but I'll just have to live with that. ;)
There was a problem hiding this comment.
Fluent interface is one thing; but we have too keep in mind that we also have immutable/persistent data structures. They don't blend well and make code hard to review. Personally, I've given up with fighting fluent interfaces but: I'd definately not approve APIs in the framework that are named WithXxx that aren't immutable withers.
| Path.GetDirectoryName(_projectPath), | ||
| library.MSBuildProject)); | ||
|
|
||
| if (string.Equals(fullDependencyProjectPath, projectFileDependencyName, StringComparison.Ordinal)) |
There was a problem hiding this comment.
It should be the same case, but that depends on MSBuild returning the same absolute path casing as Path.GetFullPath. There is probably a scenario where they will not match up, but for case-sensitive file systems you would need it.
NuGet should be using the library name all over instead since that is unique. I've opened a bug to track that work: NuGet/Home#3611
As a workaround for now you could detect if the name has a forward or back slash and then continue this path lookup, otherwise it's just the library name.
Use case-insensitive HashSets to keep track of LibraryNames, which are case-insensitive. Check if a ProjectFileDependency has a path separator, and if it does, then look for the corresponding MSBuild project with the same path to get the LibraryName.
Implement excluding <PrivateAssets>All</> dependencies during publish.
Initial setup of netci.groovy script to enable CI for standard repo
…efault Turn on view precompilation by default
This wasn't being updated and some registries/consumers appear to care.
This is the equivalent of 'type: build' dependencies in project.json.
Fix #42
@nguerrera @brthor @livarcocc @emgarten
/cc @dotnet/project-system