dotnet-installer/test/EndToEnd/ProjectBuildTests.cs

519 lines
20 KiB
C#
Raw Normal View History

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
[master] Update dependencies from dotnet/sdk (#7208) * Update dependencies from https://github.com/dotnet/sdk build 20200417.2 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.2 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.2 * Update dependencies from https://github.com/dotnet/sdk build 20200417.3 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.3 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.3 * Update dependencies from https://github.com/dotnet/sdk build 20200417.4 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.4 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.4 * Update dependencies from https://github.com/dotnet/sdk build 20200417.5 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.5 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.5 * Update dependencies from https://github.com/dotnet/sdk build 20200417.6 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.6 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.6 * Update dependencies from https://github.com/dotnet/sdk build 20200417.7 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.7 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.7 * Update dependencies from https://github.com/dotnet/sdk build 20200417.8 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.8 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20217.8 * Update dependencies from https://github.com/dotnet/sdk build 20200418.1 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.1 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.1 * Update dependencies from https://github.com/dotnet/sdk build 20200418.2 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.2 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.2 * Update dependencies from https://github.com/dotnet/sdk build 20200418.3 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.3 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.3 * Update dependencies from https://github.com/dotnet/sdk build 20200418.4 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.4 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20218.4 * Update dependencies from https://github.com/dotnet/sdk build 20200419.1 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.1 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.1 * Update dependencies from https://github.com/dotnet/sdk build 20200419.2 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.2 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.2 * Update dependencies from https://github.com/dotnet/sdk build 20200419.3 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.3 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20219.3 * Update dependencies from https://github.com/dotnet/sdk build 20200420.1 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.1 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.1 * Update dependencies from https://github.com/dotnet/sdk build 20200420.2 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.2 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.2 * Update dependencies from https://github.com/dotnet/sdk build 20200420.3 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.3 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.3 * Switch to using RuntimeInformation APIs instead of deprecated PlatformAbstractions See https://github.com/dotnet/sdk/pull/11076 * Update dependencies from https://github.com/dotnet/sdk build 20200420.4 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.4 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.4 * Update dependencies from https://github.com/dotnet/sdk build 20200420.5 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.5 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.5 * Update dependencies from https://github.com/dotnet/sdk build 20200420.7 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.7 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.7 * Update dependencies from https://github.com/dotnet/sdk build 20200420.8 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.8 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.8 * Update dependencies from https://github.com/dotnet/sdk build 20200420.10 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.10 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.10 * Update dependencies from https://github.com/dotnet/sdk build 20200420.12 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.12 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.12 * Update dependencies from https://github.com/dotnet/sdk build 20200420.13 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.13 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20220.13 * Update dependencies from https://github.com/dotnet/sdk build 20200421.1 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.1 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.1 * Update dependencies from https://github.com/dotnet/sdk build 20200421.2 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.2 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.2 * Update dependencies from https://github.com/dotnet/sdk build 20200421.3 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.3 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.3 * Update dependencies from https://github.com/dotnet/sdk build 20200421.4 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.4 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.4.20221.4 * Update dependencies from https://github.com/dotnet/sdk build 20200421.5 - Microsoft.DotNet.MSBuildSdkResolver: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.5.20221.5 - Microsoft.NET.Sdk: 5.0.100-preview.4.20217.1 -> 5.0.100-preview.5.20221.5 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Daniel Plaisted <daplaist@microsoft.com>
2020-04-21 20:54:31 +00:00
using System.Runtime.InteropServices;
using System.Xml.Linq;
using FluentAssertions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace EndToEnd.Tests
{
public class ProjectBuildTests : TestBase
{
[Fact]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
string newArgs = "console --no-restore";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
string projectPath = Path.Combine(projectDirectory, directory.Name + ".csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework").Value = TestAssetInfo.currentTfm;
project.Save(projectPath);
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
new BuildCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
var runCommand = new RunCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput()
2021-07-14 18:04:21 +00:00
.Should().Pass().And.HaveStdOutContaining("Hello, World!");
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
new CleanCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
}
[Fact]
public void ItCanRunAnAppUsingTheWebSdk()
{
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
string newArgs = "console --no-restore";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
string projectPath = Path.Combine(projectDirectory, directory.Name + ".csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
project.Root.Attribute("Sdk").Value = "Microsoft.NET.Sdk.Web";
2023-09-29 18:42:14 +00:00
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework").Value = TestAssetInfo.currentTfm;
project.Save(projectPath);
new BuildCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
var runCommand = new RunCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput()
2021-07-14 18:04:21 +00:00
.Should().Pass().And.HaveStdOutContaining("Hello, World!");
}
[WindowsOnlyTheory]
// [InlineData("net6.0", true)]
// [InlineData("net6.0", false)]
[InlineData("current", true)]
[InlineData("current", false)]
public void ItCanPublishArm64Winforms(string TargetFramework, bool selfContained)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
string TargetFrameworkParameter = "";
if (TargetFramework != "current")
{
2021-11-22 21:05:25 +00:00
TargetFrameworkParameter = $"-f {TargetFramework}";
}
string newArgs = $"winforms {TargetFrameworkParameter} --no-restore";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
string selfContainedArgs = selfContained ? " --self-contained" : "";
string publishArgs = "-r win-arm64" + selfContainedArgs;
new PublishCommand()
.WithWorkingDirectory(projectDirectory)
.Execute(publishArgs)
.Should().Pass();
[release/6.0.1xx-rc2] Update dependencies from dotnet/sdk (#12000) [release/6.0.1xx-rc2] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 6.0.0-rc.2.21459.12 to 6.0.0-rtm.21464.18 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 6.0.0-rc.2.21459.13 to 6.0.0-rc.2.21465.5 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.Net.Compilers.Toolset: from 4.0.0-5.21457.19 to 4.0.0-5.21466.5 (parent: Microsoft.NET.Sdk) - Microsoft.Build: from 17.0.0-preview-21460-01 to 17.0.0-preview-21465-01 (parent: Microsoft.NET.Sdk) - NuGet.Build.Tasks: from 6.0.0-preview.4.243 to 6.0.0-rc.244 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.SourceBuild.Intermediate.source-build: from 0.1.0-alpha.1.21460.1 to 0.1.0-alpha.1.21460.1 (parent: Microsoft.NET.Sdk) - React to https://github.com/dotnet/templating/issues/3898
2021-09-16 23:14:23 +00:00
var selfContainedPublishDir = new DirectoryInfo(projectDirectory)
.Sub("bin").Sub(TargetFramework != "current" ? "Debug" : "Release").GetDirectories().FirstOrDefault()
.Sub("win-arm64").Sub("publish");
if (selfContained)
{
selfContainedPublishDir.Should().HaveFilesMatching("System.Windows.Forms.dll", SearchOption.TopDirectoryOnly);
}
selfContainedPublishDir.Should().HaveFilesMatching($"{directory.Name}.dll", SearchOption.TopDirectoryOnly);
}
[release/6.0.1xx-rc2] Update dependencies from dotnet/sdk (#12000) [release/6.0.1xx-rc2] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 6.0.0-rc.2.21459.12 to 6.0.0-rtm.21464.18 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 6.0.0-rc.2.21459.13 to 6.0.0-rc.2.21465.5 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.Net.Compilers.Toolset: from 4.0.0-5.21457.19 to 4.0.0-5.21466.5 (parent: Microsoft.NET.Sdk) - Microsoft.Build: from 17.0.0-preview-21460-01 to 17.0.0-preview-21465-01 (parent: Microsoft.NET.Sdk) - NuGet.Build.Tasks: from 6.0.0-preview.4.243 to 6.0.0-rc.244 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.SourceBuild.Intermediate.source-build: from 0.1.0-alpha.1.21460.1 to 0.1.0-alpha.1.21460.1 (parent: Microsoft.NET.Sdk) - React to https://github.com/dotnet/templating/issues/3898
2021-09-16 23:14:23 +00:00
[WindowsOnlyTheory]
// [InlineData("net6.0", true)]
// [InlineData("net6.0", false)]
[InlineData("current", true)]
[InlineData("current", false)]
public void ItCanPublishArm64Wpf(string TargetFramework, bool selfContained)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
string TargetFrameworkParameter = "";
if (TargetFramework != "current")
{
2021-11-22 21:05:25 +00:00
TargetFrameworkParameter = $"-f {TargetFramework}";
}
string newArgs = $"wpf {TargetFrameworkParameter} --no-restore";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
string selfContainedArgs = selfContained ? " --self-contained" : "";
string publishArgs = "-r win-arm64" + selfContainedArgs;
new PublishCommand()
.WithWorkingDirectory(projectDirectory)
.Execute(publishArgs)
.Should().Pass();
var selfContainedPublishDir = new DirectoryInfo(projectDirectory)
.Sub("bin").Sub(TargetFramework != "current" ? "Debug" : "Release").GetDirectories().FirstOrDefault()
.Sub("win-arm64").Sub("publish");
if (selfContained)
{
selfContainedPublishDir.Should().HaveFilesMatching("PresentationCore.dll", SearchOption.TopDirectoryOnly);
selfContainedPublishDir.Should().HaveFilesMatching("PresentationNative_*.dll", SearchOption.TopDirectoryOnly);
}
selfContainedPublishDir.Should().HaveFilesMatching($"{directory.Name}.dll", SearchOption.TopDirectoryOnly);
}
[Theory]
// microsoft.dotnet.common.projectemplates templates
[InlineData("console")]
[InlineData("console", "C#")]
[InlineData("console", "VB")]
[InlineData("console", "F#")]
[InlineData("classlib")]
[InlineData("classlib", "C#")]
[InlineData("classlib", "VB")]
[InlineData("classlib", "F#")]
[InlineData("mstest")]
[InlineData("nunit")]
2018-11-21 02:55:46 +00:00
[InlineData("web")]
2019-05-20 19:40:08 +00:00
[InlineData("mvc")]
public void ItCanBuildTemplates(string templateName, string language = "")
{
TestTemplateCreateAndBuild(templateName, language: language);
}
2021-06-11 09:37:13 +00:00
/// <summary>
/// The test checks if dotnet new shows curated list correctly after the SDK installation and template insertion.
/// </summary>
[Fact]
public void DotnetNewShowsCuratedListCorrectly()
{
string locale = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
[release/6.0.1xx-rc2] Update dependencies from dotnet/sdk (#12000) [release/6.0.1xx-rc2] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 6.0.0-rc.2.21459.12 to 6.0.0-rtm.21464.18 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 6.0.0-rc.2.21459.13 to 6.0.0-rc.2.21465.5 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.Net.Compilers.Toolset: from 4.0.0-5.21457.19 to 4.0.0-5.21466.5 (parent: Microsoft.NET.Sdk) - Microsoft.Build: from 17.0.0-preview-21460-01 to 17.0.0-preview-21465-01 (parent: Microsoft.NET.Sdk) - NuGet.Build.Tasks: from 6.0.0-preview.4.243 to 6.0.0-rc.244 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.SourceBuild.Intermediate.source-build: from 0.1.0-alpha.1.21460.1 to 0.1.0-alpha.1.21460.1 (parent: Microsoft.NET.Sdk) - React to https://github.com/dotnet/templating/issues/3898
2021-09-16 23:14:23 +00:00
if (!string.IsNullOrWhiteSpace(locale)
&& !locale.StartsWith("en", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"[{nameof(DotnetNewShowsCuratedListCorrectly)}] CurrentUICulture: {locale}");
Console.WriteLine($"[{nameof(DotnetNewShowsCuratedListCorrectly)}] Test is skipped as it supports only 'en' or invariant culture.");
return;
}
2021-06-11 09:37:13 +00:00
string expectedOutput =
@"[\-\s]+
[\w \.\(\)]+webapp,razor\s+\[C#\][\w\ \/]+
[\w \.\(\)]+classlib\s+\[C#\],F#,VB[\w\ \/]+
[\w \.\(\)]+console\s+\[C#\],F#,VB[\w\ \/]+
2021-06-11 09:37:13 +00:00
";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
expectedOutput +=
@"[\w \.\(\)]+winforms\s+\[C#\],VB[\w\ \/]+
[\w \.\(\)]+\wpf\s+\[C#\],VB[\w\ \/]+
2021-06-11 09:37:13 +00:00
";
}
//list should end with new line
expectedOutput += Environment.NewLine;
new NewCommandShim()
.Execute()
.Should().Pass()
.And.HaveStdOutMatching(expectedOutput);
}
[Theory]
// microsoft.dotnet.common.itemtemplates templates
[InlineData("globaljson")]
[InlineData("nugetconfig")]
[InlineData("webconfig")]
[InlineData("gitignore")]
[InlineData("tool-manifest")]
[InlineData("sln")]
public void ItCanCreateItemTemplate(string templateName)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory(identifier: templateName);
string projectDirectory = directory.FullName;
string newArgs = $"{templateName}";
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
//check if the template created files
Assert.True(directory.Exists);
Assert.True(directory.EnumerateFileSystemInfos().Any());
// delete test directory for some tests so we aren't leaving behind non-compliant nuget files
if (templateName.Equals("nugetconfig"))
{
directory.Delete(true);
}
}
[Theory]
// microsoft.dotnet.common.itemtemplates templates
[InlineData("class")]
[InlineData("struct")]
[InlineData("enum")]
[InlineData("record")]
[InlineData("interface")]
[InlineData("class", "C#")]
[InlineData("class", "VB")]
[InlineData("struct", "VB")]
[InlineData("enum", "VB")]
[InlineData("interface", "VB")]
public void ItCanCreateItemTemplateWithProjectRestriction(string templateName, string language = "")
{
var languageExtensionMap = new Dictionary<string, string>()
{
{ "", ".cs" },
{ "C#", ".cs" },
{ "VB", ".vb" }
};
DirectoryInfo directory = InstantiateProjectTemplate("classlib", language, withNoRestore: false);
string projectDirectory = directory.FullName;
string expectedItemName = $"TestItem_{templateName}";
string newArgs = $"{templateName} --name {expectedItemName} --debug:ephemeral-hive";
if (!string.IsNullOrWhiteSpace(language))
{
newArgs += $" --language {language}";
}
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
//check if the template created files
Assert.True(directory.Exists);
Assert.True(directory.EnumerateFileSystemInfos().Any());
Assert.True(directory.GetFile($"{expectedItemName}.{languageExtensionMap[language]}") != null);
}
[WindowsOnlyTheory]
[InlineData("wpf")]
[InlineData("winforms")]
public void ItCanBuildDesktopTemplates(string templateName)
{
TestTemplateCreateAndBuild(templateName);
}
[WindowsOnlyTheory]
[InlineData("wpf")]
public void ItCanBuildDesktopTemplatesSelfContained(string templateName)
{
TestTemplateCreateAndBuild(templateName, selfContained: true);
}
[Theory]
[InlineData("web")]
[InlineData("console")]
public void ItCanBuildTemplatesSelfContained(string templateName)
{
TestTemplateCreateAndBuild(templateName, selfContained: true);
}
/// <summary>
/// The test checks if the template creates the template for correct framework by default.
[release/6.0.1xx-rc2] Update dependencies from dotnet/sdk (#12000) [release/6.0.1xx-rc2] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.6.0: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 6.0.0-rc.2.21460.4 to 6.0.0-rc.2.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 6.0.100-rc.2.21459.6 to 6.0.100-rtm.21465.1 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 6.0.0-rc.2.21459.12 to 6.0.0-rtm.21464.18 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 6.0.0-rc.2.21459.14 to 6.0.0-rc.2.21465.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 6.0.0-rc.2.21459.13 to 6.0.0-rc.2.21465.5 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.Net.Compilers.Toolset: from 4.0.0-5.21457.19 to 4.0.0-5.21466.5 (parent: Microsoft.NET.Sdk) - Microsoft.Build: from 17.0.0-preview-21460-01 to 17.0.0-preview-21465-01 (parent: Microsoft.NET.Sdk) - NuGet.Build.Tasks: from 6.0.0-preview.4.243 to 6.0.0-rc.244 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.6.0: from 6.0.0-rc.2.21460.8 to 6.0.0-rc.2.21464.21 (parent: Microsoft.NET.Sdk) - Microsoft.SourceBuild.Intermediate.source-build: from 0.1.0-alpha.1.21460.1 to 0.1.0-alpha.1.21460.1 (parent: Microsoft.NET.Sdk) - React to https://github.com/dotnet/templating/issues/3898
2021-09-16 23:14:23 +00:00
/// For .NET 6 the templates should create the projects targeting net6.0
/// </summary>
[Theory]
[InlineData("console")]
[InlineData("console", "C#")]
[InlineData("console", "VB")]
[InlineData("console", "F#")]
[InlineData("classlib")]
[InlineData("classlib", "C#")]
[InlineData("classlib", "VB")]
[InlineData("classlib", "F#")]
[InlineData("worker")]
[InlineData("worker", "C#")]
[InlineData("worker", "F#")]
[InlineData("mstest")]
[InlineData("mstest", "C#")]
[InlineData("mstest", "VB")]
[InlineData("mstest", "F#")]
[InlineData("nunit")]
[InlineData("nunit", "C#")]
[InlineData("nunit", "VB")]
[InlineData("nunit", "F#")]
[InlineData("xunit")]
[InlineData("xunit", "C#")]
[InlineData("xunit", "VB")]
[InlineData("xunit", "F#")]
[InlineData("blazorwasm")]
[InlineData("web")]
[InlineData("web", "C#")]
[InlineData("web", "F#")]
[InlineData("mvc")]
[InlineData("mvc", "C#")]
[InlineData("mvc", "F#")]
[InlineData("webapi")]
[InlineData("webapi", "C#")]
[InlineData("webapi", "F#")]
[InlineData("webapp")]
[InlineData("razorclasslib")]
public void ItCanCreateAndBuildTemplatesWithDefaultFramework(string templateName, string language = "")
{
2022-01-13 20:35:14 +00:00
string framework = DetectExpectedDefaultFramework(templateName);
TestTemplateCreateAndBuild(templateName, selfContained: false, language: language, framework: framework);
}
/// <summary>
/// [Windows only tests]
/// The test checks if the template creates the template for correct framework by default.
/// For .NET 6 the templates should create the projects targeting net6.0.
/// </summary>
[WindowsOnlyTheory]
[InlineData("wpf")]
[InlineData("wpf", "C#")]
[InlineData("wpf", "VB")]
[InlineData("wpflib")]
[InlineData("wpflib", "C#")]
[InlineData("wpflib", "VB")]
[InlineData("wpfcustomcontrollib")]
[InlineData("wpfcustomcontrollib", "C#")]
[InlineData("wpfcustomcontrollib", "VB")]
[InlineData("wpfusercontrollib")]
[InlineData("wpfusercontrollib", "C#")]
[InlineData("wpfusercontrollib", "VB")]
[InlineData("winforms")]
[InlineData("winforms", "C#")]
[InlineData("winforms", "VB")]
[InlineData("winformslib")]
[InlineData("winformslib", "C#")]
[InlineData("winformslib", "VB")]
[InlineData("winformscontrollib")]
[InlineData("winformscontrollib", "C#")]
[InlineData("winformscontrollib", "VB")]
public void ItCanCreateAndBuildTemplatesWithDefaultFramework_Windows(string templateName, string language = "")
{
[main] Update dependencies from dotnet/sdk (#12826) [main] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 7.0.0-alpha.1.21609.2 to 7.0.0-alpha.1.21615.7 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 7.0.0-alpha.1.21611.1 to 7.0.0-alpha.1.21615.8 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.NET.Test.Sdk: from 17.2.0-preview-20211214-01 to 17.2.0-preview-20211214-03 (parent: Microsoft.NET.Sdk) - Microsoft.NET.ILLink.Tasks: from 7.0.100-1.21613.2 to 7.0.100-1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Update default tf from winforms templates.
2021-12-17 21:28:08 +00:00
string framework = DetectExpectedDefaultFramework(templateName);
TestTemplateCreateAndBuild(templateName, selfContained: false, language: language, framework: $"{framework}-windows");
}
/// <summary>
/// [project is not built on linux-musl]
/// The test checks if the template creates the template for correct framework by default.
/// For .NET 6 the templates should create the projects targeting net6.0.
/// </summary>
[Theory]
[InlineData("grpc")]
public void ItCanCreateAndBuildTemplatesWithDefaultFramework_DisableBuildOnLinuxMusl(string templateName)
{
string framework = DetectExpectedDefaultFramework(templateName);
if (RuntimeInformation.RuntimeIdentifier.StartsWith("linux-musl"))
{
TestTemplateCreateAndBuild(templateName, build: false, framework: framework);
}
else
{
TestTemplateCreateAndBuild(templateName, selfContained: true, framework: framework);
}
}
[main] Update dependencies from dotnet/sdk (#12826) [main] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 7.0.0-alpha.1.21609.2 to 7.0.0-alpha.1.21615.7 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 7.0.0-alpha.1.21611.1 to 7.0.0-alpha.1.21615.8 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.NET.Test.Sdk: from 17.2.0-preview-20211214-01 to 17.2.0-preview-20211214-03 (parent: Microsoft.NET.Sdk) - Microsoft.NET.ILLink.Tasks: from 7.0.100-1.21613.2 to 7.0.100-1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Update default tf from winforms templates.
2021-12-17 21:28:08 +00:00
private static string DetectExpectedDefaultFramework(string template = "")
{
string dotnetFolder = Path.GetDirectoryName(RepoDirectoriesProvider.DotnetUnderTest);
string[] runtimeFolders = Directory.GetDirectories(Path.Combine(dotnetFolder, "shared", "Microsoft.NETCore.App"));
int latestMajorVersion = runtimeFolders.Select(folder => int.Parse(Path.GetFileName(folder).Split('.').First())).Max();
if (latestMajorVersion == 9)
{
2022-01-13 19:23:58 +00:00
return $"net{latestMajorVersion}.0";
}
[main] Update dependencies from dotnet/sdk (#12826) [main] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.WindowsDesktop.App.Ref: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.WindowsDesktop.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Ref: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.TargetingPack.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref.Internal: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 7.0.0-alpha.1.21613.11 to 7.0.0-alpha.1.21616.8 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.TemplateEngine.Cli: from 7.0.100-alpha.1.21613.3 to 7.0.100-alpha.1.21617.2 (parent: Microsoft.NET.Sdk) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.Dotnet.WinForms.ProjectTemplates: from 7.0.0-alpha.1.21609.2 to 7.0.0-alpha.1.21615.7 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.WindowsDesktop.App.Runtime.win-x64: from 7.0.0-alpha.1.21611.2 to 7.0.0-alpha.1.21616.1 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Wpf.ProjectTemplates: from 7.0.0-alpha.1.21611.1 to 7.0.0-alpha.1.21615.8 (parent: Microsoft.WindowsDesktop.App.Runtime.win-x64) - Microsoft.NET.Test.Sdk: from 17.2.0-preview-20211214-01 to 17.2.0-preview-20211214-03 (parent: Microsoft.NET.Sdk) - Microsoft.NET.ILLink.Tasks: from 7.0.100-1.21613.2 to 7.0.100-1.21616.1 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.NetCore.SharedFramework.x64.7.0: from 7.0.0-alpha.1.21612.5 to 7.0.0-alpha.1.21616.17 (parent: Microsoft.NET.Sdk) - Update default tf from winforms templates.
2021-12-17 21:28:08 +00:00
throw new Exception("Unsupported version of SDK");
}
private static void TestTemplateCreateAndBuild(string templateName, bool build = true, bool selfContained = false, string language = "", string framework = "", bool deleteTestDirectory = false)
{
DirectoryInfo directory = InstantiateProjectTemplate(templateName, language);
string projectDirectory = directory.FullName;
if (!string.IsNullOrWhiteSpace(framework))
{
//check if MSBuild TargetFramework property for *proj is set to expected framework
string expectedExtension = language switch
{
"C#" => "*.csproj",
"F#" => "*.fsproj",
"VB" => "*.vbproj",
_ => "*.csproj"
};
string projectFile = Directory.GetFiles(projectDirectory, expectedExtension).Single();
XDocument projectXml = XDocument.Load(projectFile);
XNamespace ns = projectXml.Root.Name.Namespace;
Assert.Equal(framework, projectXml.Root.Element(ns + "PropertyGroup").Element(ns + "TargetFramework").Value);
}
if (build)
{
string buildArgs = selfContained ? $"-r {RuntimeInformation.RuntimeIdentifier} --self-contained" : "";
if (!string.IsNullOrWhiteSpace(framework))
{
buildArgs += $" --framework {framework}";
}
// Remove this (or formalize it) after https://github.com/dotnet/installer/issues/12479 is resolved.
if (language == "F#")
{
buildArgs += $" /p:_NETCoreSdkIsPreview=true";
}
string dotnetRoot = Path.GetDirectoryName(RepoDirectoriesProvider.DotnetUnderTest);
new BuildCommand()
.WithEnvironmentVariable("PATH", dotnetRoot) // override PATH since razor rely on PATH to find dotnet
.WithWorkingDirectory(projectDirectory)
.Execute(buildArgs)
.Should().Pass();
}
// delete test directory for some tests so we aren't leaving behind non-compliant package files
if (deleteTestDirectory)
{
directory.Delete(true);
}
}
private static DirectoryInfo InstantiateProjectTemplate(string templateName, string language = "", bool withNoRestore = true)
{
DirectoryInfo directory = TestAssets.CreateTestDirectory(
identifier: string.IsNullOrWhiteSpace(language)
? templateName
: $"{templateName}[{language}]");
string projectDirectory = directory.FullName;
string newArgs = $"{templateName} --debug:ephemeral-hive {(withNoRestore ? "--no-restore" : "")}";
if (!string.IsNullOrWhiteSpace(language))
{
newArgs += $" --language {language}";
}
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute(newArgs)
.Should().Pass();
return directory;
}
}
}