Skip to content

Commit

Permalink
Mark Microsoft.AspNetCore.App and Microsoft.AspNetCore.All as implici…
Browse files Browse the repository at this point in the history
…tly defined (#119)

Certain versions of the ASP.NET Core SDK do not mark these package references as implicitly defined which causes build errors in CentralPackageVersions.

Fixes #118
  • Loading branch information
jeffkl committed Jul 12, 2019
1 parent 58d934f commit 913832f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,48 @@ public void LogErrorIfProjectSpecifiesVersionAndVersionOverrideIsDisabled(string
buildOutput.Errors.ShouldBe(new[] { $"The package reference \'Foo\' should not specify a version. Please specify the version in \'{packagesProps.FullPath}\'." });
}

[Fact]
public void MicrosoftAspNetCoreAllUpdated()
{
WritePackagesProps();

ProjectCreator.Templates
.SdkCsproj(
path: Path.Combine(TestRootPath, "test.csproj"),
targetFramework: "netcoreapp2.0",
sdk: "Microsoft.NET.Sdk.Web",
projectCreator: creator => creator
.ItemPackageReference("Microsoft.AspNetCore.All")
.Import(Path.Combine(Environment.CurrentDirectory, @"Sdk\Sdk.targets")))
.TryGetItems("PackageReference", out IReadOnlyCollection<ProjectItem> items);

items.Where(i => i.EvaluatedInclude.Equals("Microsoft.AspNetCore.All"))
.ShouldHaveSingleItem()
.GetMetadataValue("IsImplicitlyDefined")
.ShouldBe("true");
}

[Fact]
public void MicrosoftAspNetCoreAppUpdated()
{
WritePackagesProps();

ProjectCreator.Templates
.SdkCsproj(
path: Path.Combine(TestRootPath, "test.csproj"),
targetFramework: "netcoreapp2.0",
sdk: "Microsoft.NET.Sdk.Web",
projectCreator: creator => creator
.ItemPackageReference("Microsoft.AspNetCore.App")
.Import(Path.Combine(Environment.CurrentDirectory, @"Sdk\Sdk.targets")))
.TryGetItems("PackageReference", out IReadOnlyCollection<ProjectItem> items);

items.Where(i => i.EvaluatedInclude.Equals("Microsoft.AspNetCore.App"))
.ShouldHaveSingleItem()
.GetMetadataValue("IsImplicitlyDefined")
.ShouldBe("true");
}

[Theory]
[InlineData(".csproj")]
[InlineData(".fsproj")]
Expand Down
11 changes: 11 additions & 0 deletions src/CentralPackageVersions/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
Condition="'$(MSBuildProjectExtension)' == '.fsproj' And '$(DisableImplicitSystemValueTupleReference)' != 'true' And '$(UpdateImplicitSystemValueTupleReference)' != 'false' And '$(TargetFrameworkIdentifier)' == '.NETFramework' And '$(_TargetFrameworkVersionWithoutV)' &gt;= '4.0' And '$(_TargetFrameworkVersionWithoutV)' &lt;= '4.7'"
IsImplicitlyDefined="true" />

<!--
Workaround the issue where Microsoft.AspNet.App and Microsoft.AspNet.All are not marked as implicitly defined
-->
<PackageReference Update="Microsoft.AspNetCore.App"
Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'"
IsImplicitlyDefined="true" />

<PackageReference Update="Microsoft.AspNetCore.All"
Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'"
IsImplicitlyDefined="true" />

<!--
Store a list of <PackageReference /> items that specified a Version so that an error can be displayed.
-->
Expand Down

0 comments on commit 913832f

Please sign in to comment.