-
Notifications
You must be signed in to change notification settings - Fork 742
Add ability to disable the writing of the dependency graph spec file #7239
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,7 @@ public partial class JsonPackageSpecReader | |
| private static readonly byte[] SdkAnalysisLevel = Encoding.UTF8.GetBytes("SdkAnalysisLevel"); | ||
| private static readonly byte[] UsingMicrosoftNETSdk = Encoding.UTF8.GetBytes("UsingMicrosoftNETSdk"); | ||
| private static readonly byte[] UseLegacyDependencyResolverPropertyName = Encoding.UTF8.GetBytes("restoreUseLegacyDependencyResolver"); | ||
| private static readonly byte[] RestoreDoNotWriteDependencyGraphSpecPropertyName = Encoding.UTF8.GetBytes("restoreDoNotWriteDependencyGraphSpec"); | ||
|
Member
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. I wonder if this should be a part of the no-op invalidation. Like in theory, if I went from no to yes, I'd want the dgspec to be regenerated, but I know there's been attempts at using CI data to make local restores more efficient. My only concern with not adding it though is it becoming out of date.
Contributor
Author
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. Yeah I was worried about special casing any particular property, just in case that little detail is lost in the overall design. I could go either way...
Member
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. Whoever is using CI caching can just not set this anyways. Will this be enabled across all of 1ES or just whenever wanted? |
||
| private static readonly byte[] PackagesToPrunePropertyName = Encoding.UTF8.GetBytes("packagesToPrune"); | ||
|
|
||
| internal static PackageSpec GetPackageSpecUtf8JsonStreamReader(Stream stream, string name, string packageSpecPath, IEnvironmentVariableReader environmentVariableReader, string snapshotValue = null) | ||
|
|
@@ -775,6 +776,7 @@ private static void ReadMSBuildMetadata(ref Utf8JsonStreamReader jsonReader, Pac | |
| bool usingMicrosoftNetSdk = true; | ||
| NuGetVersion sdkAnalysisLevel = null; | ||
| bool useLegacyDependencyResolver = false; | ||
| bool restoreDoNotWriteDependencyGraphSpec = false; | ||
|
|
||
| if (jsonReader.Read() && jsonReader.TokenType == JsonTokenType.StartObject) | ||
| { | ||
|
|
@@ -1033,6 +1035,10 @@ private static void ReadMSBuildMetadata(ref Utf8JsonStreamReader jsonReader, Pac | |
| { | ||
| useLegacyDependencyResolver = jsonReader.ReadNextTokenAsBoolOrThrowAnException(UseLegacyDependencyResolverPropertyName, Strings.Invalid_AttributeValue); | ||
| } | ||
| else if (jsonReader.ValueTextEquals(RestoreDoNotWriteDependencyGraphSpecPropertyName)) | ||
| { | ||
| restoreDoNotWriteDependencyGraphSpec = jsonReader.ReadNextTokenAsBoolOrThrowAnException(RestoreDoNotWriteDependencyGraphSpecPropertyName, Strings.Invalid_AttributeValue); | ||
| } | ||
| else | ||
| { | ||
| jsonReader.Skip(); | ||
|
|
@@ -1061,6 +1067,7 @@ private static void ReadMSBuildMetadata(ref Utf8JsonStreamReader jsonReader, Pac | |
| msbuildMetadata.SdkAnalysisLevel = sdkAnalysisLevel; | ||
| msbuildMetadata.UsingMicrosoftNETSdk = usingMicrosoftNetSdk; | ||
| msbuildMetadata.UseLegacyDependencyResolver = useLegacyDependencyResolver; | ||
| msbuildMetadata.RestoreDoNotWriteDependencyGraphSpec = restoreDoNotWriteDependencyGraphSpec; | ||
|
|
||
| if (configFilePaths != null) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,12 @@ public class ProjectRestoreMetadata : IEquatable<ProjectRestoreMetadata> | |
|
|
||
| public bool UseLegacyDependencyResolver { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether or not the dependency graph spec file should not be written during restore. | ||
| /// The default value is <see langword="false" />. | ||
| /// </summary> | ||
| public bool RestoreDoNotWriteDependencyGraphSpec { get; set; } | ||
|
Member
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. get; init; maybe? Get it right from the start since we want these to be immutable eventually. I wish I had added UseLegacyDependencyResolver as a get init. :D |
||
|
|
||
| public override int GetHashCode() | ||
| { | ||
| StringComparer osStringComparer = PathUtility.GetStringComparerBasedOnOS(); | ||
|
|
@@ -182,6 +188,7 @@ public override int GetHashCode() | |
| hashCode.AddObject(UsingMicrosoftNETSdk); | ||
| hashCode.AddObject(SdkAnalysisLevel); | ||
| hashCode.AddObject(UseLegacyDependencyResolver); | ||
| hashCode.AddObject(RestoreDoNotWriteDependencyGraphSpec); | ||
|
|
||
| return hashCode.CombinedHash; | ||
| } | ||
|
|
@@ -230,7 +237,8 @@ public bool Equals(ProjectRestoreMetadata other) | |
| RestoreAuditProperties == other.RestoreAuditProperties && | ||
| UsingMicrosoftNETSdk == other.UsingMicrosoftNETSdk && | ||
| EqualityUtility.EqualsWithNullCheck(SdkAnalysisLevel, other.SdkAnalysisLevel) && | ||
| UseLegacyDependencyResolver == other.UseLegacyDependencyResolver; | ||
| UseLegacyDependencyResolver == other.UseLegacyDependencyResolver && | ||
| RestoreDoNotWriteDependencyGraphSpec == other.RestoreDoNotWriteDependencyGraphSpec; | ||
| } | ||
|
|
||
| private HashSet<string> GetSources(IList<PackageSource> sources) | ||
|
|
@@ -284,6 +292,7 @@ protected void FillClone(ProjectRestoreMetadata clone) | |
| clone.SdkAnalysisLevel = SdkAnalysisLevel; | ||
| clone.UsingMicrosoftNETSdk = UsingMicrosoftNETSdk; | ||
| clone.UseLegacyDependencyResolver = UseLegacyDependencyResolver; | ||
| clone.RestoreDoNotWriteDependencyGraphSpec = RestoreDoNotWriteDependencyGraphSpec; | ||
| } | ||
| } | ||
| } | ||
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.
nit: extra newline.