Anthony Mastrean
Anthony Mastrean

Reputation: 22404

How are dependencies managed in `dotnet` templates?

When I create a new test project with .NET Core 1.0.4 (SDK)

$ dotnet new mstest

I see an outdated Microsoft.NET.Test.Sdk in the .csproj (15.0.0, when 15.3.0 is released).

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
    <PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
  </ItemGroup>

</Project>

When are these dependencies updated in the template? At different SDK versions? Can I upgrade the template on my system? Or am I stuck upgrading every new project manually?


I upgraded to .NET Core 2.0 (SDK) and tried again and now I get a pre-release version of the same dependency! What gives?

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
    <PackageReference Include="MSTest.TestFramework" Version="1.1.18" />
  </ItemGroup>

</Project>

Upvotes: 0

Views: 334

Answers (1)

Roman Patutin
Roman Patutin

Reputation: 2210

Currently work with template is much more easy then previously. Templating is extracted into separated project from dotnet (dotnet/templating). You can always get used template from github, change what you want and install into your machine.

Source code for template for mstest project is stored here

Steps to fix:

  1. Get sources for template from github and save it somewhere in your local drive (I used D:\Temp\MSTest-CSharp).

  2. Change version of packages inside the Company.TestProject1.csproj

  3. Install new version of template using dotnet new -i command. In my case it looks like

    dotnet new -i d:\Temp\MSTest-CSharp

And after that every time when you will use dotnet new mstest it will new template with yours set of libraries.

Upvotes: 1

Related Questions