diff --git a/bin/add-practice-exercise.ps1 b/bin/add-practice-exercise.ps1 index 3658e011c..a6043717b 100644 --- a/bin/add-practice-exercise.ps1 +++ b/bin/add-practice-exercise.ps1 @@ -33,18 +33,23 @@ $exerciseName = (Get-Culture).TextInfo.ToTitleCase($Exercise).Replace("-", "") $exerciseDir = "exercises/practice/${Exercise}" $projectFile = "${exerciseDir}/${ExerciseName}.csproj" & dotnet new install xunit.v3.templates -& dotnet new xunit3 --force --output $exerciseDir --name $ExerciseName +& dotnet new xunit3 --force --framework net9.0 --output $exerciseDir --name $ExerciseName & dotnet sln exercises/Exercises.sln add $projectFile [xml]$project = Get-Content $projectFile $project.Project.PropertyGroup.RemoveChild($project.Project.PropertyGroup.SelectSingleNode("//comment()")) $project.Project.PropertyGroup.RemoveChild($project.Project.PropertyGroup.SelectSingleNode("//RootNamespace")) +$restorePackagesWithLockFileElement = $project.CreateElement("RestorePackagesWithLockFile"); +$restorePackagesWithLockFileElement.InnerText = "true" +$project.Project.PropertyGroup.AppendChild($restorePackagesWithLockFileElement) $project.Project.RemoveChild($project.Project.ItemGroup[0]) $project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='Microsoft.NET.Test.Sdk']").SetAttribute("Version", "17.12.0") $project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.v3']").SetAttribute("Version", "1.1.0") -$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.runner.visualstudio']").SetAttribute("Version", "3.0.2") +$project.Project.ItemGroup[1].SelectSingleNode("PackageReference[@Include='xunit.runner.visualstudio']").SetAttribute("Version", "3.0.1") $project.Save($projectFile) +dotnet add $projectFile package Exercism.Tests.xunit.v3 --version 0.1.0-beta1 + # Remove and update files Remove-Item -Path "${exerciseDir}/xunit.runner.json" Remove-Item -Path "${exerciseDir}/UnitTest1.cs" diff --git a/generators/TemplateGenerator.cs b/generators/TemplateGenerator.cs index 59d3078d5..bd3909159 100644 --- a/generators/TemplateGenerator.cs +++ b/generators/TemplateGenerator.cs @@ -61,9 +61,6 @@ private static bool ExpectsError(this JsonNode testCase) => testCase["expected"] is JsonObject jsonObject && jsonObject.ContainsKey("error"); private const string GeneratorTemplate = @" -{{ if error }}using System;{{ end }} -using Xunit; - public class {%{{{ testClass }}}%} { {%{{{- for test in tests }}}%}