Skip to content

Trying to install NUnit 3.6.1 on .NET Framework asks for download of 20 more packages #2165

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

Closed
Jivko1212 opened this issue May 13, 2017 · 15 comments
Assignees
Milestone

Comments

@Jivko1212
Copy link

I can install NUnit on .Net Framework 4.6.1 without a problem but when I try to install it via Nuget on the newly released 4.7 it asks for these packages:
capture

And this is only half of the list

@rprouse
Copy link
Member

rprouse commented May 15, 2017

It looks like when you target 4.7 that NuGet decides to reference the .NET Standard version of NUnit rather than the .NET 4.5 version. Technically both are correct, but I would think the .NET 4.5 would be more correct.

A fix would be to put a copy of the .NET 4.5 assembly in a net47 directory in the NuGet package. We might also be able to put a .props file in the net47 directory that points to the DLL in the net45 directory.

When we fix this, we should also check .NET 4.6.2 and even 4.6.1 when included from the new CSPROJ format.

Speaking of, @Jivko1212, is your .NET 4.7 project using the new CSPROJ format?

@CharliePoole
Copy link
Member

On a slightly related note, see nunit/dotnet-test-nunit#118

@Caleb9
Copy link

Caleb9 commented May 17, 2017

Speaking of, @Jivko1212, is your .NET 4.7 project using the new CSPROJ format?

@rprouse I'm suffering from the same issue and yes, it's CSPROJ format.

@rprouse
Copy link
Member

rprouse commented May 17, 2017

@Caleb9 is it the new style csproj introduced in 2017 that doesn't include any of the cs files, like the project file at the end of this blog post?

@Caleb9
Copy link

Caleb9 commented May 18, 2017

@rprouse I don't think so. I'm developing in VS 2017 but the project was created still in 2015 and it does contain some <Compile Include="Properties\AssemblyInfo.cs" /> etc. references. The top of the file looks like this

<?xml version="1.0" encoding="utf-8"?>                                                                               
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{2FC5A3A7-A9CF-4392-AC36-1C11A71BCF45}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Test.Unit.Project</RootNamespace>
    <AssemblyName>Test.Unit.Project</AssemblyName>
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>   <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>rogramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>est>False</IsCodedUITest>
    <TestProjectType>UnitTest</TestProjectType>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

so I'm guessing it's the old style?

@rprouse rprouse self-assigned this May 18, 2017
@rprouse
Copy link
Member

rprouse commented May 18, 2017

Yup, that's old style, thanks. I will perform some tests and create a fix. I will likely wait until the .NET Standard pull request is merged otherwise there will be conflicts in the NuGet file and I also want to see how .NET Standard 1.3 behaves.

@rprouse
Copy link
Member

rprouse commented May 18, 2017

Test Target NUnit Reference Pulls in Extra NuGet References
4.5.2 4.5 No
4.6 4.5 Yes
4.6.2 4.5 Yes
4.7 4.5 Yes

I created test projects targeting the above framework and referenced NUnit. Looking in the project files, they all correctly target the .NET 4.5 version of the framework, but .NET 4.6 and above project pull in all the extra dependencies.

I then tried to install another similar NuGet package and it did not display the same behaviour. The only difference I see is that theirs explicitly states no-dependencies for the .NET 4.5 and other frameworks, where we don't say anything. I am testing that hypothesis...

@rprouse
Copy link
Member

rprouse commented May 18, 2017

Adding empty dependencies groups does fix the issue. I am working on the .NET Standard branch because the Nuspec files is changed too much to not conflict, so I will include the fix for this in that PR.

The dependencies in the nuspec now look like this,

    <dependencies>
      <group targetFramework="net20" />
      <group targetFramework="net35" />
      <group targetFramework="net40" />
      <group targetFramework="net45" />
      <group targetFramework="netstandard1.3">
        <dependency id="NETStandard.Library" version="1.6.0" />
        <dependency id="System.Threading.Thread" version="4.3.0" />
      </group>
      <group targetFramework="netstandard1.6">
        <dependency id="NETStandard.Library" version="1.6.0" />
        <dependency id="System.Runtime.Loader" version="4.3.0" />
        <dependency id="System.Threading.Thread" version="4.3.0" />
      </group>
    </dependencies>

@Jivko1212
Copy link
Author

Just wanted to add that I am able to install NUnit on 4.6.1 without pulling extra dependencies. I had a similar issue with NSubstitute and though that this is due to the following table:

https://docs.microsoft.com/en-us/dotnet/articles/standard/library

it says here that 4.6.1 supports .NET Standard up to 2.0, while 4.6.2 doesn't.

@jnm2
Copy link
Contributor

jnm2 commented May 19, 2017

@Jivko1212 Oh boy, they keep having to clarify that chart. net462 is a superset of net461. Because net461 supports netstandard20, net462 supports netstandard20 as well. That chart is listing the minimum version supporting, not the maximum version. The change from ".NET Framework (with tooling 1.0)" to ".NET Framework (with tooling 2.0)" actually made .NET Framework more compatible earlier.

@jnm2
Copy link
Contributor

jnm2 commented May 19, 2017

@Jivko1212 Another way to look at it:

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Framework (with tooling 1.0) 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.6.1, 4.6.2, 4.7, vNext 4.6.2, 4.7, vNext vNext 4.6.1, 4.6.2, 4.7, vNext
.NET Framework (with tooling 2.0) 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.6, 4.6.1, 4.6.2, 4.7, vNext 4.6.1, 4.6.2, 4.7, vNext 4.6.1, 4.6.2, 4.7, vNext 4.6.1, 4.6.2, 4.7, vNext 4.6.1, 4.6.2, 4.7, vNext

@Jivko1212
Copy link
Author

Hi thanks for the much better chart .. it is strange though that both NUnit and NSubstitute work perfectly on 4.6.1 but ask to download ton of packages on 4.6.2 .. no idea why .. this is the reason I am developing on 4.6.1 as opposed to 4.6.2 and 4.7 now

@jnm2
Copy link
Contributor

jnm2 commented May 19, 2017

It looks like @rprouse figured out what was causing it.

Looks like NuGet uses the best matching target framework dependency group. Without the empty groups, net452 and earlier cannot match any dependency group and have no extra packages, but net46 - net47 match the netstandard1.3 group and that is the only group they could match.

Now with the empty groups, net46 - net47 match the all the groups net20, net35, net40, net45 and netstandard1.3 instead of just netstandard1.3, and NuGet selects net45 as the closest match out of the bunch. The net45 dependency group is empty and voila.

@rprouse
Copy link
Member

rprouse commented May 19, 2017

@Jivko1212 I saw 4.6.2 causing problems because I was using an updated version of NUnit that includes dependencies for .NET Standard 1.3. The released version only has dependencies for .NET Standard 1.6.

@jnm2
Copy link
Contributor

jnm2 commented May 19, 2017

Oh, I left out the fact that with the new .NET Core tooling net461 - net47 also match the netstandard1.6 group. But if net45 is present that is the better match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants