-
Notifications
You must be signed in to change notification settings - Fork 694
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
Add lib placeholder files for Visual Studio restores #1251
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,34 +330,53 @@ public static LockFileTargetLibrary CreateLockFileTargetProject( | |
// Add files under asset groups | ||
object filesObject; | ||
object msbuildPath; | ||
if (localMatch.LocalLibrary.Items.TryGetValue(KnownLibraryProperties.ProjectRestoreMetadataFiles, out filesObject) | ||
&& localMatch.LocalLibrary.Items.TryGetValue(KnownLibraryProperties.MSBuildProjectPath, out msbuildPath)) | ||
if (localMatch.LocalLibrary.Items.TryGetValue(KnownLibraryProperties.MSBuildProjectPath, out msbuildPath)) | ||
{ | ||
var files = (List<ProjectRestoreMetadataFile>)filesObject; | ||
var files = new List<ProjectRestoreMetadataFile>(); | ||
var fileLookup = new Dictionary<string, ProjectRestoreMetadataFile>(StringComparer.OrdinalIgnoreCase); | ||
|
||
foreach (var file in files) | ||
// Find the project path, this is provided by the resolver | ||
var msbuildFilePathInfo = new FileInfo((string)msbuildPath); | ||
|
||
// Ensure a trailing slash for the relative path helper. | ||
var projectDir = msbuildFilePathInfo.Directory.FullName | ||
.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; | ||
|
||
// Read files from the project if they were provided. | ||
if (localMatch.LocalLibrary.Items.TryGetValue(KnownLibraryProperties.ProjectRestoreMetadataFiles, out filesObject)) | ||
{ | ||
files.AddRange((List<ProjectRestoreMetadataFile>)filesObject); | ||
} | ||
|
||
var targetFrameworkShortName = targetGraph.Framework.GetShortFolderName(); | ||
var libAnyPath = $"lib/{targetFrameworkShortName}/any.dll"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it standard to use forward slashes everywhere in the assets file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, they must be forward slashes |
||
|
||
if (files.Count == 0) | ||
{ | ||
var path = file.PackagePath; | ||
// If the project did not provide a list of assets, add in default ones. | ||
// These are used to detect transitive vs non-transitive project references. | ||
var absolutePath = Path.Combine(projectDir, "bin", "placeholder", $"{localMatch.Library.Name}.dll"); | ||
|
||
files.Add(new ProjectRestoreMetadataFile(libAnyPath, absolutePath)); | ||
} | ||
|
||
// Process and de-dupe files | ||
for (var i = 0; i < files.Count; i++) | ||
{ | ||
var path = files[i].PackagePath; | ||
|
||
// LIBANY avoid compatibility checks and will always be used. | ||
if (LIBANY.Equals(path, StringComparison.Ordinal)) | ||
{ | ||
path = $"lib/{targetGraph.Framework.GetShortFolderName()}/any.dll"; | ||
path = libAnyPath; | ||
} | ||
|
||
if (!fileLookup.ContainsKey(path)) | ||
{ | ||
fileLookup.Add(path, file); | ||
fileLookup.Add(path, files[i]); | ||
} | ||
} | ||
|
||
var msbuildFilePathInfo = new FileInfo((string)msbuildPath); | ||
|
||
// Ensure a trailing slash for the relative path helper. | ||
var projectDir = msbuildFilePathInfo.Directory.FullName | ||
.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; | ||
|
||
var contentItems = new ContentItemCollection(); | ||
contentItems.Load(fileLookup.Keys); | ||
|
||
|
@@ -483,7 +502,7 @@ private static IEnumerable<LockFileItem> GetBuildItemsForPackageId( | |
yield return props; | ||
} | ||
|
||
var targets = ordered.FirstOrDefault(c => | ||
var targets = ordered.FirstOrDefault(c => | ||
$"{packageId}.targets".Equals( | ||
Path.GetFileName(c.Path), | ||
StringComparison.OrdinalIgnoreCase)); | ||
|
@@ -572,7 +591,7 @@ private static LockFileItem ToResourceLockFileItem(ContentItem item) | |
/// Clears a lock file group and replaces the first item with _._ if | ||
/// the group has items. Empty groups are left alone. | ||
/// </summary> | ||
private static void ClearIfExists<T>(IList<T> group) where T: LockFileItem | ||
private static void ClearIfExists<T>(IList<T> group) where T : LockFileItem | ||
{ | ||
if (GroupHasNonEmptyItems(group)) | ||
{ | ||
|
@@ -592,7 +611,7 @@ private static void ClearIfExists<T>(IList<T> group) where T: LockFileItem | |
group.Clear(); | ||
|
||
// Create a new item with the _._ path | ||
var emptyItem = (T)Activator.CreateInstance(typeof(T), new [] { emptyDir }); | ||
var emptyItem = (T)Activator.CreateInstance(typeof(T), new[] { emptyDir }); | ||
|
||
// Copy over the properties from the first | ||
foreach (var pair in firstItem.Properties) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a helper method in PathUtility for this..perhaps use that instead for consistency?