Block PackAsTool invalid TFMs#2152
Conversation
| {2} - Current version of platform package</comment> | ||
| </data> | ||
| </root> No newline at end of file | ||
| <data name="PackAsToolOnlySupportNetcoreapp" xml:space="preserve"> |
There was a problem hiding this comment.
@KathleenDollard for this 2 strings
"DotnetTool only supports .NET Core."
"DotnetTool does not support target framework lower than netcoreapp2.1."
There was a problem hiding this comment.
What is "DotnetTool" in this message? Is this supposed to refer to the PackAsTool property?
There was a problem hiding this comment.
Global tools feature officially is called DotnetTool, since it is the nuget package type. And Rob once asked in mail for official name, that is the one. However, it does not stick that well
| <NETSdkError Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" | ||
| ResourceName="PackAsToolOnlySupportNetcoreapp" /> | ||
|
|
||
| <NETSdkError Condition="'$(_TargetFrameworkVersionWithoutV)' < '2.1'" |
There was a problem hiding this comment.
Should I access _TargetFrameworkVersionWithoutV or calculate it again. It is created by SDK, but it is a previous process.
hard code 2.1 is fine? it is a hard number
There was a problem hiding this comment.
Better to use 2.1.0 to be absolutely sure msbuild does not coerce to float instead of version.
There was a problem hiding this comment.
As long as it's in one place only and we have near zero expectation of changing it again, I think hard-coding is actually fine and honestly more readable.
|
|
||
| // walk around attribute require static | ||
| string message = null; | ||
| if (error == "PackAsToolDoesNotSupportTFMLowerThanNetcoreapp21") |
There was a problem hiding this comment.
I don't know a better way to walk around it
| [InlineData("TargetFrameworks", "netcoreapp2.0;netcoreapp2.1", "PackAsToolDoesNotSupportTFMLowerThanNetcoreapp21")] | ||
| // non netcoreapp | ||
| [InlineData("TargetFramework", "net46", "PackAsToolOnlySupportNetcoreapp")] | ||
| [InlineData("TargetFramework", "netstandard2.0", "PackAsToolOnlySupportNetcoreapp")] |
There was a problem hiding this comment.
And I will explicit block full framework and netstarnard. They should not work in the beginning
|
|
||
| // walk around attribute requires static | ||
| string message = null; | ||
| if (error == "PackAsToolDoesNotSupportTFMLowerThanNetcoreapp21") |
There was a problem hiding this comment.
I cannot find a better way to walk around attribute need to be static
There was a problem hiding this comment.
Can you use the same code that is generated for you in the properties? IE:
string message = Microsoft.NET.Build.Tasks.Strings.ResourceManager.GetString(error);Also I'd rename error to something like expectedErrorResourceName and message to expectedErrorMessage.
| [FullMSBuildOnlyFact] | ||
| public void It_should_fail_with_error_message_on_fullframework() | ||
| { | ||
| It_should_fail_with_error_message("TargetFramework", "net46", "PackAsToolOnlySupportNetcoreapp"); |
There was a problem hiding this comment.
I am blocking full framework. It should not work in the beginning
There was a problem hiding this comment.
@KathleenDollard I am blocking full framework and netstandard at the same time.
There was a problem hiding this comment.
Yes, let's notify on pack if it will fail later when we can.
I don't think I've seen a message on netstandard.
There was a problem hiding this comment.
No, but for netstandard it is pretty much impossible to create one. There is no entry point for the program at all. It will fail later down the road, but in this case it can fail more explicitly with better error message.
dsplaisted
left a comment
There was a problem hiding this comment.
Looks good, although it looks like you still need to figure out how to do the version comparison correctly without having the versions be interpreted as floats. Also lets wait for #2157 if possible and then you can remove all the NuGetConfigWriter calls.
| {2} - Current version of platform package</comment> | ||
| </data> | ||
| </root> No newline at end of file | ||
| <data name="PackAsToolOnlySupportNetcoreapp" xml:space="preserve"> |
There was a problem hiding this comment.
What is "DotnetTool" in this message? Is this supposed to refer to the PackAsTool property?
|
|
||
| mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
| value : The object must be serialized into a byte array | ||
| value : The object must be serialized into a byte array |
There was a problem hiding this comment.
Did you edit this file manually? Where are all the whitespace changes coming from? It would be good to revert them.
There was a problem hiding this comment.
I edit by double click in VS. I don't know where they come from. But let me revert it
| .Restore(Log); | ||
| }); | ||
|
|
||
| List<string> sources = new List<string>() { NuGetConfigWriter.DotnetCoreMyGetFeed }; |
There was a problem hiding this comment.
I think this workaround will be unnecessary once we merge #2157
|
|
||
| // walk around attribute requires static | ||
| string message = null; | ||
| if (error == "PackAsToolDoesNotSupportTFMLowerThanNetcoreapp21") |
There was a problem hiding this comment.
Can you use the same code that is generated for you in the properties? IE:
string message = Microsoft.NET.Build.Tasks.Strings.ResourceManager.GetString(error);Also I'd rename error to something like expectedErrorResourceName and message to expectedErrorMessage.
| result.StdOut.Should().Contain(message); | ||
| } | ||
|
|
||
| [FullMSBuildOnlyFact] |
There was a problem hiding this comment.
I think this should be WindowsOnlyFact instead of FullMSBuildOnlyFact.
There was a problem hiding this comment.
will windows always has full framework? my understanding is fullmsbuild will have fullframework. And windows can have only dotnet core like nano
There was a problem hiding this comment.
We don't run our tests on nano though. There are lots of other tests that assume that full framework is available on Windows.
If we want to support running the tests on Windows without the full framework (and full framework reference assemblies) installed, then we can make our Fact/Theory attributes more granular to represent this, but for now we should get the coverage on the .NET CLI as well as full MSBuild.
| ResourceName="DotnetToolOnlySupportNetcoreapp" /> | ||
|
|
||
| <!-- Compare version in System.Version type, if it is lower than 2.1 --> | ||
| <NETSdkError Condition='$([System.Version]::Parse("$(_TargetFrameworkVersionWithoutV)").CompareTo($([System.Version]::Parse("2.1")))) < 0' |
There was a problem hiding this comment.
@nguerrera as we discussed. use msbuild compare may cause problem on 2.11 vs 2.2. This looks ugly but it works. @rainersigwald is it supported? I cannot find a direct document about it.
Also $([System.Version]::Parse("2.1")) seems keep the type. If I just replace it with string 2.1 it will error and ask for Version type.
The alternative is to write a Task. It is a lot of code and also it might not be cleaner than that.
dd64791 to
dc544da
Compare
Only netcoreapp2.1 and up is valid. Everything else will fail later down the road.
https://github.com/dotnet/cli/issues/9073