Skip to content

Commit 4c90d91

Browse files
Fix new exercise (#2414)
1 parent 328b5f4 commit 4c90d91

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

bin/add-practice-exercise.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,23 @@ $exerciseName = (Get-Culture).TextInfo.ToTitleCase($Exercise).Replace("-", "")
3333
$exerciseDir = "exercises/practice/${Exercise}"
3434
$projectFile = "${exerciseDir}/${ExerciseName}.csproj"
3535
& dotnet new install xunit.v3.templates
36-
& dotnet new xunit3 --force --output $exerciseDir --name $ExerciseName
36+
& dotnet new xunit3 --force --framework net9.0 --output $exerciseDir --name $ExerciseName
3737
& dotnet sln exercises/Exercises.sln add $projectFile
3838

3939
[xml]$project = Get-Content $projectFile
4040
$project.Project.PropertyGroup.RemoveChild($project.Project.PropertyGroup.SelectSingleNode("//comment()"))
4141
$project.Project.PropertyGroup.RemoveChild($project.Project.PropertyGroup.SelectSingleNode("//RootNamespace"))
42+
$restorePackagesWithLockFileElement = $project.CreateElement("RestorePackagesWithLockFile");
43+
$restorePackagesWithLockFileElement.InnerText = "true"
44+
$project.Project.PropertyGroup.AppendChild($restorePackagesWithLockFileElement)
4245
$project.Project.RemoveChild($project.Project.ItemGroup[0])
4346
$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='Microsoft.NET.Test.Sdk']").SetAttribute("Version", "17.12.0")
4447
$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.v3']").SetAttribute("Version", "1.1.0")
45-
$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.runner.visualstudio']").SetAttribute("Version", "3.0.2")
48+
$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.runner.visualstudio']").SetAttribute("Version", "3.0.1")
4649
$project.Save($projectFile)
4750

51+
dotnet add $projectFile package Exercism.Tests.xunit.v3 --version 0.1.0-beta1
52+
4853
# Remove and update files
4954
Remove-Item -Path "${exerciseDir}/xunit.runner.json"
5055
Remove-Item -Path "${exerciseDir}/UnitTest1.cs"

generators/TemplateGenerator.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ private static bool ExpectsError(this JsonNode testCase) =>
6161
testCase["expected"] is JsonObject jsonObject && jsonObject.ContainsKey("error");
6262

6363
private const string GeneratorTemplate = @"
64-
{{ if error }}using System;{{ end }}
65-
using Xunit;
66-
6764
public class {%{{{ testClass }}}%}
6865
{
6966
{%{{{- for test in tests }}}%}

0 commit comments

Comments
 (0)