-
Notifications
You must be signed in to change notification settings - Fork 697
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
Fix invalid target framework error for Solution restore #6091
base: dev
Are you sure you want to change the base?
Conversation
src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs
Outdated
Show resolved
Hide resolved
a83cf34
to
6abdca3
Compare
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.
There's some test failures that seem like actual failures.
It's also worth calling out in the description that this is only a CLI problem in the PR description and that VS errors are way better.
@@ -458,6 +458,12 @@ private static IEnumerable<TargetFrameworkInformation> GetTargetFrameworkInforma | |||
foreach (var item in GetItemByType(items, "TargetFrameworkInformation")) | |||
{ | |||
var frameworkString = item.GetProperty("TargetFramework"); | |||
if (frameworkString.Contains(';')) |
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.
Throwing from here probably leads to a bad failure in NuGet.exe?
In general, NuGet.exe expects a dg spec to create an this fails that.
Can you double check NuGet.exe?
6abdca3
to
ec1bbf6
Compare
[Theory] | ||
[InlineData("net40;net45")] | ||
[InlineData("net40;net45 ; netstandard2.0 ")] | ||
public void GetOriginalTargetFramework_WhenTargetFramworkSpecified_HasCorrectTargetFramework(string targetFrameworks) |
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.
public void GetOriginalTargetFramework_WhenTargetFramworkSpecified_HasCorrectTargetFramework(string targetFrameworks) | |
public void GetOriginalTargetFramework_WhenMultipleTargetFramworkSpecified_ThrowRestoreCommandException(string targetFrameworks) |
Might want to change the name of this test.
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Bug
Fixes: NuGet/Home#13772
Description
There is a difference in behavior when doing a restore in Solution vs Project with an invalid target framework in the
<TargetFramework>
tag. When doing it in the project Level, sdk will run a validation before doing restore in https://github.com/dotnet/sdk/blob/5ab26633bdf4676efa25140a31a3d6182efb02f9/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets#L92.The problem is that Solution level does not this validation (since it doesn't run a restore for each project) and will fail with
This PR adds a validation and return the same error message as the project level. Currently, I decided to error with a NuGet error but we could also add
NETSDK1046
in the error message.PR Checklist