d6cab4af58
* Move dotnet-new templates to Sdk attribute * Update to MSBuild 15.1.0-preview-000454-01 To pick up a fix for Microsoft/msbuild#1431. * Fix template newlines * Fix casing on Microsoft.Net.Sdk * Move migration test csproj's to Sdk attribute * Disable parallel sdk restore Each SDK restore operation will try to manipulate the same assets.json file since the dependency name&version are injected into a common csproj file. This can cause runtime failures when two NuGets try to restore the project at once. * Make casing of SDK 'NET' and not 'Net' * Remove redundatn imports * Fix test string * Additional race * Replacing the SDK with the Web.Sdk when it is a Web project. * Fixing the test by writting the csproj before running the migration rule.
128 lines
No EOL
5.8 KiB
C#
128 lines
No EOL
5.8 KiB
C#
// 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 Microsoft.Build.Construction;
|
|
using Microsoft.DotNet.ProjectJsonMigration;
|
|
using Microsoft.DotNet.Internal.ProjectModel;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using NuGet.Frameworks;
|
|
using System.Linq;
|
|
using Xunit;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.ProjectJsonMigration.Rules;
|
|
|
|
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|
{
|
|
public class GivenThatIWantToMigrateAssemblyInfo : TestBase
|
|
{
|
|
private ProjectRootElement _mockProject;
|
|
|
|
public GivenThatIWantToMigrateAssemblyInfo()
|
|
{
|
|
var projectDirectory =
|
|
TestAssetsManager.CreateTestInstance("AppWithAssemblyInfo").Path;
|
|
var projectContext =
|
|
ProjectContext.Create(projectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
|
_mockProject = ProjectRootElement.Create();
|
|
var testSettings = new MigrationSettings(projectDirectory, projectDirectory, _mockProject, null);
|
|
var testInputs = new MigrationRuleInputs(
|
|
new[] {projectContext},
|
|
_mockProject,
|
|
_mockProject.AddItemGroup(),
|
|
_mockProject.AddPropertyGroup());
|
|
|
|
new MigrateAssemblyInfoRule().Apply(testSettings, testInputs);
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyCompanyAttributeToFalseWhenAssemblyCompanyExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyCompanyAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyConfigurationAttributeToFalseWhenAssemblyConfigurationExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyConfigurationAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyCopyrightAttributeToFalseWhenAssemblyCopyrightExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyCopyrightAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyDescriptionAttributeToFalseWhenAssemblyDescriptionExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyDescriptionAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyFileVersionAttributeToFalseWhenAssemblyFileVersionExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyFileVersionAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyInformationalVersionAttributeToFalseWhenAssemblyInformationalVersionExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyInformationalVersionAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyProductAttributeToFalseWhenAssemblyProductExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyProductAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyTitleAttributeToFalseWhenAssemblyTitleExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyTitleAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateAssemblyVersionAttributeToFalseWhenAssemblyVersionExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateAssemblyVersionAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
|
|
[Fact]
|
|
public void ItSetsGenerateNeutralResourcesLanguageAttributeToFalseWhenNeutralResourcesLanguageExists()
|
|
{
|
|
var generateAssemblyAttributes =
|
|
_mockProject.Properties.Where(p => p.Name.Equals("GenerateNeutralResourcesLanguageAttribute", StringComparison.Ordinal));
|
|
generateAssemblyAttributes.Count().Should().Be(1);
|
|
generateAssemblyAttributes.First().Value.Should().Be("false");
|
|
}
|
|
}
|
|
} |