Skip to content

Implement excluding <PrivateAssets>All</> dependencies during publish. - #212

Merged
eerhardt merged 3 commits into
dotnet:masterfrom
eerhardt:PrivateAssets
Oct 7, 2016
Merged

eerhardt merged 3 commits into
dotnet:masterfrom
eerhardt:PrivateAssets

Conversation

@eerhardt

@eerhardt eerhardt commented Oct 5, 2016

Copy link
Copy Markdown
Member

This is the equivalent of 'type: build' dependencies in project.json.

Fix #42

@nguerrera @brthor @livarcocc @emgarten

/cc @dotnet/project-system

This is the equivalent of 'type: build' dependencies in project.json.

Fix #42
@@ -0,0 +1,173 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this ignore case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If not, this line is equivalent to the more succinct if (fullDependencyProjectPath == projectFileDependencyName)

@eerhardt eerhardt Oct 6, 2016 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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.

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.

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>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar question, all of these tables are case-sensitive by design, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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;

@nguerrera nguerrera Oct 6, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cc @terrajobst. Irrespective of fluency, 'with' is an especially bad naming choice for something that has a side-effect IMHO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

x.WithY(y) changing x is really unfortunate.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't bother. I give up. 😢

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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. ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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))

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.

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.
@eerhardt
eerhardt merged commit de03497 into dotnet:master Oct 7, 2016
nguerrera pushed a commit that referenced this pull request Oct 10, 2016
Implement excluding <PrivateAssets>All</> dependencies during publish.
sbomer pushed a commit to sbomer/sdk that referenced this pull request Sep 19, 2017
Initial setup of netci.groovy script to enable CI for standard repo
mmitche pushed a commit to mmitche/sdk that referenced this pull request Jun 5, 2020
…efault

Turn on view precompilation by default
GangWang01 pushed a commit to GangWang01/sdk that referenced this pull request Mar 20, 2023
This wasn't being updated and some registries/consumers appear to care.
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.

4 participants