-
Notifications
You must be signed in to change notification settings - Fork 695
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
error when TPV is missing from target frameworks #3616
Conversation
|
|
I think if the obj folder is clean, then yes, pack will fail. But if they have a valid project, restore so an assets file is created, then change the project so they don't have a TPV, I don't know what will happen if they try to pack. I was also wondering if we need to do any checks if the customer packs with a custom nuspec, but I guess we don't validate any other |
I think adding it to pack might be a reasonable suggestion.
Pack shouldn't happen if a restore fails. Build shouldn't happen if a restore fails. |
if (!string.IsNullOrEmpty(targetFramework)) | ||
{ | ||
var fw = NuGetFramework.Parse(targetFramework); | ||
if (!string.IsNullOrEmpty(fw.Platform) && fw.PlatformVersion == FrameworkConstants.EmptyVersion) |
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.
!string.IsNullOrEmpty(fw.Platform) && fw.PlatformVersion == FrameworkConstants.EmptyVersion [](start = 24, length = 91)
Just for my understanding, is there a case where having a PlatformVersion without a Platform is valid?
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.
nope!
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.
In that case, do we need the first check for fw.Platform?
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.
if (!string.IsNullOrEmpty(fw.Platform) && fw.PlatformVersion == FrameworkConstants.EmptyVersion) | |
if (fw.PlatformVersion == FrameworkConstants.EmptyVersion) |
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.
Oh, yes we do, because "PlatformVersion" will be EmptyVersion when Platform is empty, and we only wanna do this check when we definitely have a platform.
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.
Looks like a great start.
I think we should make sure we cover the manual edit scenarios in the test.
In particular, nuspec packing where both the targetframework is specified in the dependency group and when the file structure is created by the customer.
ie verify that someone can't just add a
lib/net50/mylib.dll
src/NuGet.Core/NuGet.Commands/CommandRunners/PackCommandRunner.cs
Outdated
Show resolved
Hide resolved
3bddcfb
to
27d89d0
Compare
if (!string.IsNullOrEmpty(targetFramework)) | ||
{ | ||
var fw = NuGetFramework.Parse(targetFramework); | ||
if (!string.IsNullOrEmpty(fw.Platform) && fw.PlatformVersion == FrameworkConstants.EmptyVersion) |
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.
if (!string.IsNullOrEmpty(fw.Platform) && fw.PlatformVersion == FrameworkConstants.EmptyVersion) | |
if (fw.PlatformVersion == FrameworkConstants.EmptyVersion) |
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.
Can we please cover manual nuspec scenarios + advanced pack targeting scenarios where the user manually redirects to a folder using PackagePath.
In particular I think we need to handle the following scenarios:
- A customer manually writes a nuspec, and in the DependencyGroups specifies a version such as
net5.0-windows
- A customer manually writes a nuspec, and uses the file element and puts a dll in a directory such as
lib\net5.0-windows
. - A customer says
<IncludeBuildOutput>false</IncludeBuildOutput>
. And then uses one of the following: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificbuildoutput, and redirects manually usingPackagePath
.
I know these scenarios might be new, so grab some time with me if you need help crafting the tests.
{ | ||
foreach (NuGetFramework fw in badPlatforms) | ||
{ | ||
_logger.Log(RestoreLogMessage.CreateError(NuGetLogCode.NU1012, string.Format(CultureInfo.CurrentCulture, Strings.Error_PlatformVersionNotPresent, fw.Framework, fw.Platform))); |
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: In an ideal world, I'd recommend these get merged so that a user gets only 1 instead of N errors, but I simply don't see this scenario getting hit too often (actually I'd only expect it during development), so I would not bother too much :)
@heng-liu I don't think this change was ready to be merged |
* error when TPV is missing from dependencies Fixes: NuGet/Home#9441
We should probably create a follow-up here to make sure all scenarios are covered. We might be adding just tests, but I don't have high confidence that we don't need more product changes. |
Fixes: NuGet/Home#9441