Skip to content

Move all of DataProtection and Extensions.Identity to netstandard2.0 #11008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 83 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2675203
Revert "Use CryptographicOperations.FixedTimeEquals (#9798)"
HaoK Jun 7, 2019
80e86b4
Switch some of DP and Identity.Core to netstandard 2.0
HaoK Jun 7, 2019
e7d5f09
Move stores to netstandard2.0
HaoK Jun 7, 2019
16a5e10
Update src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.As…
HaoK Jun 8, 2019
bcd4b8e
Update src/Identity/Extensions.Core/src/PasswordHasher.cs
HaoK Jun 8, 2019
4a87377
Update src/Identity/Extensions.Core/src/Microsoft.Extensions.Identity…
HaoK Jun 8, 2019
fc19548
PR feedback
HaoK Jun 8, 2019
8cf8e8d
Update a bunch of refs
HaoK Jun 8, 2019
2829811
Put dataprotection back to netcoreapp3.0 for now so things build
HaoK Jun 8, 2019
f28900b
Update refs
HaoK Jun 8, 2019
f02644e
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
5de40f5
Update Microsoft.AspNetCore.Cryptography.Internal.csproj
HaoK Jun 12, 2019
a662525
Update Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj
HaoK Jun 12, 2019
7c53dfc
Update Microsoft.Extensions.Identity.Core.csproj
HaoK Jun 12, 2019
6252612
Update Microsoft.Extensions.Identity.Stores.csproj
HaoK Jun 12, 2019
6b23703
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
b68d597
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
00035ba
Switch Startup filter to HostedService
HaoK Jun 18, 2019
3b9eb26
Update refs
HaoK Jun 18, 2019
23d0085
Remove netcoreapp ref
HaoK Jun 18, 2019
98d5b66
Update all the rest of the packages to netstandard2/2.1
HaoK Jun 18, 2019
847ccd7
Update src/DataProtection/DataProtection/src/Microsoft.AspNetCore.Dat…
HaoK Jun 18, 2019
434830c
Update SharedFramework.Local.props
HaoK Jun 19, 2019
6b9c4fe
Update Microsoft.AspNetCore.DataProtection.Extensions.csproj
HaoK Jun 19, 2019
26f34c8
Update SharedFramework.Local.props
HaoK Jun 19, 2019
5f60ba2
Add generic host key ring loading test
HaoK Jun 19, 2019
b18fc54
Start hosted services before server
HaoK Jun 19, 2019
0648edf
Temporarily skip SignalR TS client tests (#11398)
BrennanConroy Jun 19, 2019
a9a9298
Make SSEMessageFormatter internal and use new InternalsVisibleTo patt…
mikaelm12 Jun 20, 2019
5079006
Add file manifest for runtime and targeting pack (#11235)
jkotalik Jun 20, 2019
0b5d4ba
Remove copy race for IIS projects (#11394)
jkotalik Jun 20, 2019
689b052
Convert TLS connection adapter to connection middleware (#11109)
jkotalik Jun 20, 2019
f27b029
Add ConfigureWebHost to generic test
HaoK Jun 20, 2019
0058a58
Fix Template test runs on macOS and Linux (#11407)
Jun 20, 2019
56ffc6b
On RenderTreeBuilder, add SetUpdatesAttributeName (#11375)
SteveSandersonMS Jun 20, 2019
eca80cf
Supressbaseline references
HaoK Jun 20, 2019
c987ce5
Add Invoke API with with no completion result (#11399)
mikaelm12 Jun 20, 2019
e8181ae
Pass options to HubConnectionContext (#11382)
BrennanConroy Jun 20, 2019
af94089
Update Microsoft.Extensions.Identity.Stores.csproj
HaoK Jun 20, 2019
21fdbcd
Allow @bind-value to be specified on its own (#11401)
ajaybhargavb Jun 20, 2019
c5d62b4
Quarantine some tests (#11420)
analogrelay Jun 20, 2019
25d5688
Remove connection adapters and move things to middleware (#11412)
davidfowl Jun 20, 2019
e95c3a0
Kestrel Override Client Cert Validation (#11423)
mikaelm12 Jun 21, 2019
0d92fee
Work around potential race in PipeWriter (IIS Edition) (#11165)
halter73 Jun 21, 2019
495f529
Remove redundant call to UseAuthentication (#11426)
Tratcher Jun 21, 2019
5ce20eb
Do not exit cleanly after failed `msbuild` in `build.ps1`'s `finally`…
dougbu Jun 17, 2019
f6c3f9e
Avoid calling AuthenticateAsync for IIS out-of-proc #7750 (#11390)
Tratcher Jun 21, 2019
7f3e2ac
Use Enterprise Queue to reduce provisioning issues (#11434)
Jun 21, 2019
83faa32
Update Microsoft.AspNetCore.DataProtection.csproj
HaoK Jun 21, 2019
edf8bbe
[master] Update dependencies from aspnet/AspNetCore-Tooling aspnet/Bl…
dotnet-maestro[bot] Jun 21, 2019
f9aa85a
Dylan/stack policy (#11293)
DylanDmitri Jun 21, 2019
f01cdfd
Revert "Use CryptographicOperations.FixedTimeEquals (#9798)"
HaoK Jun 7, 2019
517279b
Switch some of DP and Identity.Core to netstandard 2.0
HaoK Jun 7, 2019
161a10c
Move stores to netstandard2.0
HaoK Jun 7, 2019
d324750
Update src/DataProtection/Cryptography.KeyDerivation/src/Microsoft.As…
HaoK Jun 8, 2019
6803e60
Update src/Identity/Extensions.Core/src/PasswordHasher.cs
HaoK Jun 8, 2019
71deed6
Update src/Identity/Extensions.Core/src/Microsoft.Extensions.Identity…
HaoK Jun 8, 2019
e09ea72
PR feedback
HaoK Jun 8, 2019
f5ee4ea
Update a bunch of refs
HaoK Jun 8, 2019
9621ae1
Put dataprotection back to netcoreapp3.0 for now so things build
HaoK Jun 8, 2019
4bd9102
Update refs
HaoK Jun 8, 2019
9e762b8
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
4e87ea9
Update Microsoft.AspNetCore.Cryptography.Internal.csproj
HaoK Jun 12, 2019
45e22af
Update Microsoft.AspNetCore.Cryptography.KeyDerivation.csproj
HaoK Jun 12, 2019
5e835aa
Update Microsoft.Extensions.Identity.Core.csproj
HaoK Jun 12, 2019
4293c95
Update Microsoft.Extensions.Identity.Stores.csproj
HaoK Jun 12, 2019
2a0a816
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
5f42399
Update Microsoft.AspNetCore.DataProtection.Abstractions.csproj
HaoK Jun 12, 2019
4a52b3b
Switch Startup filter to HostedService
HaoK Jun 18, 2019
b768a6d
Update refs
HaoK Jun 18, 2019
6b5aab2
Remove netcoreapp ref
HaoK Jun 18, 2019
91ab870
Update all the rest of the packages to netstandard2/2.1
HaoK Jun 18, 2019
83a0f23
Update src/DataProtection/DataProtection/src/Microsoft.AspNetCore.Dat…
HaoK Jun 18, 2019
dac155a
Update SharedFramework.Local.props
HaoK Jun 19, 2019
93fc8cc
Update Microsoft.AspNetCore.DataProtection.Extensions.csproj
HaoK Jun 19, 2019
e52ae2e
Update SharedFramework.Local.props
HaoK Jun 19, 2019
35a495e
Add generic host key ring loading test
HaoK Jun 19, 2019
e4c4210
Start hosted services before server
HaoK Jun 19, 2019
5649460
Add ConfigureWebHost to generic test
HaoK Jun 20, 2019
0f10e30
Supressbaseline references
HaoK Jun 20, 2019
1945c83
Update Microsoft.Extensions.Identity.Stores.csproj
HaoK Jun 20, 2019
478a5ea
Fix whitespace
HaoK Jun 21, 2019
d9d7d0d
Merge branch 'data-netstd' of https://github.com/aspnet/AspNetCore in…
HaoK Jun 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .azure/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ jobs:
- bash: "./eng/scripts/install-nginx-mac.sh"
displayName: Installing Nginx
afterBuild:
- bash: ./build.sh --ci --pack --no-build --no-restore --no-build-deps "/bl:artifacts/log/packages.pack.binlog"
displayName: Pack Packages (for Template tests)
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore --no-build-deps "/bl:artifacts/log/template.pack.binlog"
displayName: Pack Templates (for Template tests)
- bash: ./build.sh --no-build --ci --test -p:RunFlakyTests=true
displayName: Run Flaky Tests
continueOnError: true
Expand All @@ -456,6 +460,10 @@ jobs:
- bash: "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"
displayName: Increase inotify limit
afterBuild:
- bash: ./build.sh --ci --pack --no-build --no-restore --no-build-deps "/bl:artifacts/log/packages.pack.binlog"
displayName: Pack Packages (for Template tests)
- bash: ./src/ProjectTemplates/build.sh --ci --pack --no-restore --no-build-deps "/bl:artifacts/log/template.pack.binlog"
displayName: Pack Templates (for Template tests)
- bash: ./build.sh --no-build --ci --test -p:RunFlakyTests=true
displayName: Run Flaky Tests
continueOnError: true
Expand Down
8 changes: 2 additions & 6 deletions .azure/pipelines/jobs/default-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ jobs:
queue: BuildPool.Windows.10.Amd64.VS2019.Open
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCoreInternal-Pool
${{ if ne(parameters.isTestingJob, true) }}:
# Visual Studio Build Tools
queue: BuildPool.Windows.10.Amd64.VS2019.BT
${{ if eq(parameters.isTestingJob, true) }}:
# Visual Studio Enterprise - contains some stuff, like SQL Server and IIS Express, that we use for testing
queue: BuildPool.Windows.10.Amd64.VS2019
# Visual Studio Enterprise - contains some stuff, like SQL Server and IIS Express, that we use for testing
queue: BuildPool.Windows.10.Amd64.VS2019
variables:
AgentOsName: ${{ parameters.agentOs }}
ASPNETCORE_TEST_LOG_MAXPATH: "200" # Keep test log file name length low enough for artifact zipping
Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
<SharedFxName>Microsoft.AspNetCore.App</SharedFxName>
<SharedFxDescription>Shared Framework for hosting of Microsoft ASP.NET Core applications. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub ($(RepositoryUrl)). We happily accept issues and PRs.</SharedFxDescription>

<NETCoreAppFrameworkIdentifier>.NETCoreApp</NETCoreAppFrameworkIdentifier>
<NETCoreAppFramework>netcoreapp$(AspNetCoreMajorMinorVersion)</NETCoreAppFramework>
<AspNetCoreAppFrameworkBrandName>ASP.NET Core $(AspNetCoreMajorMinorVersion)</AspNetCoreAppFrameworkBrandName>

<TargetingPackName>Microsoft.AspNetCore.App.Ref</TargetingPackName>
<RuntimeInstallerBaseName>aspnetcore-runtime</RuntimeInstallerBaseName>
<TargetingPackInstallerBaseName>aspnetcore-targeting-pack</TargetingPackInstallerBaseName>
Expand Down
13 changes: 11 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ if ($tmpBinaryLog) {
# Capture MSBuild crash logs
$env:MSBUILDDEBUGPATH = $LogDir

$local:exit_code = $null
try {
# Import custom tools configuration, if present in the repo.
# Note: Import in global scope so that the script set top-level variables without qualification.
Expand All @@ -342,6 +343,10 @@ try {

$restore = $tmpRestore

if ($ci) {
$global:VerbosePreference = 'Continue'
}

if (-not $NoBuildRepoTasks) {
MSBuild $toolsetBuildProj `
/p:RepoRoot=$RepoRoot `
Expand All @@ -359,9 +364,13 @@ try {
catch {
Write-Host $_.ScriptStackTrace
Write-PipelineTaskError -Message $_
ExitWithExitCode 1
$exit_code = 1
}
finally {
if (! $exit_code) {
$exit_code = $LASTEXITCODE
}

# tools.ps1 corrupts global state, so reset these values so they don't carry between invocations of build.ps1
rm variable:global:_BuildTool -ea Ignore
rm variable:global:_DotNetInstallDir -ea Ignore
Expand All @@ -378,4 +387,4 @@ finally {
}
}

ExitWithExitCode 0
ExitWithExitCode $exit_code
3 changes: 3 additions & 0 deletions eng/SharedFramework.External.props
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
This references are part of Microsoft.NETCore.App, so are listed here as references to be used during compilation only.
-->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
<_CompilationOnlyReference Include="Microsoft.Win32.Registry" />
<_CompilationOnlyReference Include="System.Security.Cryptography.Cng" />
<_CompilationOnlyReference Include="System.Security.Principal.Windows" />
<_CompilationOnlyReference Include="System.Buffers" />
<_CompilationOnlyReference Include="System.ComponentModel.Annotations" />
<_CompilationOnlyReference Include="System.Runtime.CompilerServices.Unsafe" />
Expand Down
14 changes: 7 additions & 7 deletions eng/SharedFramework.Local.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
<Project>
<ItemGroup>
<!-- These assemblies are available as both a NuGet package and in the shared framework -->
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.DataProtection.Abstractions" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Cryptography.Internal" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.DataProtection" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.DataProtection.Extensions" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Http.Features" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Metadata" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.Extensions.Identity.Core" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.Extensions.Identity.Stores" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Connections.Abstractions" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Authorization" />
<AspNetCoreAppReferenceAndPackage Include="Microsoft.AspNetCore.Http.Connections.Common" />
Expand All @@ -20,11 +27,6 @@

<!-- These assemblies are only in the shared framework -->
<AspNetCoreAppReference Include="Microsoft.AspNetCore" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Cryptography.Internal" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.DataProtection" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.DataProtection.Extensions" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Antiforgery" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Hosting" />
Expand All @@ -40,8 +42,6 @@
<AspNetCoreAppReference Include="Microsoft.AspNetCore.WebUtilities" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Html.Abstractions" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Identity" />
<AspNetCoreAppReference Include="Microsoft.Extensions.Identity.Core" />
<AspNetCoreAppReference Include="Microsoft.Extensions.Identity.Stores" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Server.HttpSys" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<AspNetCoreAppReference Include="Microsoft.AspNetCore.Server.IIS" />
Expand Down
20 changes: 10 additions & 10 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
-->
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.AspNetCore.Blazor.Mono" Version="0.10.0-preview7.19310.1">
<Dependency Name="Microsoft.AspNetCore.Blazor.Mono" Version="0.10.0-preview7.19317.1">
<Uri>https://github.com/aspnet/Blazor</Uri>
<Sha>fc20643ca2493c56180e4f5a00946116a3b6afdc</Sha>
<Sha>03f3e4a1a88037d9bbdd21334706ff147d616148</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.Razor.Language" Version="3.0.0-preview7.19316.1">
<Dependency Name="Microsoft.AspNetCore.Razor.Language" Version="3.0.0-preview7.19320.3">
<Uri>https://github.com/aspnet/AspNetCore-Tooling</Uri>
<Sha>271045bfd76b339ab1c8b2555507ad727b068aa3</Sha>
<Sha>a399bd072e04f394de843ac100bd16fdd926a993</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="3.0.0-preview7.19316.1">
<Dependency Name="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="3.0.0-preview7.19320.3">
<Uri>https://github.com/aspnet/AspNetCore-Tooling</Uri>
<Sha>271045bfd76b339ab1c8b2555507ad727b068aa3</Sha>
<Sha>a399bd072e04f394de843ac100bd16fdd926a993</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Razor" Version="3.0.0-preview7.19316.1">
<Dependency Name="Microsoft.CodeAnalysis.Razor" Version="3.0.0-preview7.19320.3">
<Uri>https://github.com/aspnet/AspNetCore-Tooling</Uri>
<Sha>271045bfd76b339ab1c8b2555507ad727b068aa3</Sha>
<Sha>a399bd072e04f394de843ac100bd16fdd926a993</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Sdk.Razor" Version="3.0.0-preview7.19316.1">
<Dependency Name="Microsoft.NET.Sdk.Razor" Version="3.0.0-preview7.19320.3">
<Uri>https://github.com/aspnet/AspNetCore-Tooling</Uri>
<Sha>271045bfd76b339ab1c8b2555507ad727b068aa3</Sha>
<Sha>a399bd072e04f394de843ac100bd16fdd926a993</Sha>
</Dependency>
<Dependency Name="dotnet-ef" Version="3.0.0-preview7.19313.2">
<Uri>https://github.com/aspnet/EntityFrameworkCore</Uri>
Expand Down
10 changes: 5 additions & 5 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<!-- Only listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->
<MicrosoftNETCorePlatformsPackageVersion>3.0.0-preview7.19312.3</MicrosoftNETCorePlatformsPackageVersion>
<!-- Packages from aspnet/Blazor -->
<MicrosoftAspNetCoreBlazorMonoPackageVersion>0.10.0-preview7.19310.1</MicrosoftAspNetCoreBlazorMonoPackageVersion>
<MicrosoftAspNetCoreBlazorMonoPackageVersion>0.10.0-preview7.19317.1</MicrosoftAspNetCoreBlazorMonoPackageVersion>
<!-- Packages from aspnet/Extensions -->
<InternalAspNetCoreAnalyzersPackageVersion>3.0.0-preview7.19312.4</InternalAspNetCoreAnalyzersPackageVersion>
<MicrosoftAspNetCoreAnalyzerTestingPackageVersion>3.0.0-preview7.19312.4</MicrosoftAspNetCoreAnalyzerTestingPackageVersion>
Expand Down Expand Up @@ -154,10 +154,10 @@
<MicrosoftEntityFrameworkCoreToolsPackageVersion>3.0.0-preview7.19313.2</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftEntityFrameworkCorePackageVersion>3.0.0-preview7.19313.2</MicrosoftEntityFrameworkCorePackageVersion>
<!-- Packages from aspnet/AspNetCore-Tooling -->
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>3.0.0-preview7.19316.1</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
<MicrosoftAspNetCoreRazorLanguagePackageVersion>3.0.0-preview7.19316.1</MicrosoftAspNetCoreRazorLanguagePackageVersion>
<MicrosoftCodeAnalysisRazorPackageVersion>3.0.0-preview7.19316.1</MicrosoftCodeAnalysisRazorPackageVersion>
<MicrosoftNETSdkRazorPackageVersion>3.0.0-preview7.19316.1</MicrosoftNETSdkRazorPackageVersion>
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>3.0.0-preview7.19320.3</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
<MicrosoftAspNetCoreRazorLanguagePackageVersion>3.0.0-preview7.19320.3</MicrosoftAspNetCoreRazorLanguagePackageVersion>
<MicrosoftCodeAnalysisRazorPackageVersion>3.0.0-preview7.19320.3</MicrosoftCodeAnalysisRazorPackageVersion>
<MicrosoftNETSdkRazorPackageVersion>3.0.0-preview7.19320.3</MicrosoftNETSdkRazorPackageVersion>
</PropertyGroup>
<!--

Expand Down
107 changes: 107 additions & 0 deletions eng/tools/RepoTasks/CreateFrameworkListFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace RepoTasks
{
public class CreateFrameworkListFile : Task
{
/// <summary>
/// Files to extract basic information from and include in the list.
/// </summary>
[Required]
public ITaskItem[] Files { get; set; }

[Required]
public string TargetFile { get; set; }

/// <summary>
/// Extra attributes to place on the root node.
///
/// %(Identity): Attribute name.
/// %(Value): Attribute value.
/// </summary>
public ITaskItem[] RootAttributes { get; set; }

public override bool Execute()
{
XAttribute[] rootAttributes = RootAttributes
?.Select(item => new XAttribute(item.ItemSpec, item.GetMetadata("Value")))
.ToArray();

var frameworkManifest = new XElement("FileList", rootAttributes);

var usedFileProfiles = new HashSet<string>();

foreach (var f in Files
.Select(item => new
{
Item = item,
Filename = Path.GetFileName(item.ItemSpec),
TargetPath = item.GetMetadata("TargetPath"),
AssemblyName = FileUtilities.GetAssemblyName(item.ItemSpec),
FileVersion = FileUtilities.GetFileVersion(item.ItemSpec),
IsNative = item.GetMetadata("IsNativeImage") == "true",
IsSymbolFile = item.GetMetadata("IsSymbolFile") == "true"
})
.Where(f =>
!f.IsSymbolFile &&
(f.Filename.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || f.IsNative))
.OrderBy(f => f.TargetPath, StringComparer.Ordinal)
.ThenBy(f => f.Filename, StringComparer.Ordinal))
{
var element = new XElement(
"File",
new XAttribute("Type", f.IsNative ? "Native" : "Managed"),
new XAttribute(
"Path",
Path.Combine(f.TargetPath, f.Filename).Replace('\\', '/')));

if (f.AssemblyName != null)
{
byte[] publicKeyToken = f.AssemblyName.GetPublicKeyToken();
string publicKeyTokenHex;

if (publicKeyToken != null)
{
publicKeyTokenHex = BitConverter.ToString(publicKeyToken)
.ToLowerInvariant()
.Replace("-", "");
}
else
{
Log.LogError($"No public key token found for assembly {f.Item.ItemSpec}");
publicKeyTokenHex = "";
}

element.Add(
new XAttribute("AssemblyName", f.AssemblyName.Name),
new XAttribute("PublicKeyToken", publicKeyTokenHex),
new XAttribute("AssemblyVersion", f.AssemblyName.Version));
}
else if (!f.IsNative)
{
// This file isn't managed and isn't native. Leave it off the list.
continue;
}

element.Add(new XAttribute("FileVersion", f.FileVersion));

frameworkManifest.Add(element);
}

Directory.CreateDirectory(Path.GetDirectoryName(TargetFile));
File.WriteAllText(TargetFile, frameworkManifest.ToString());

return !Log.HasLoggedErrors;
}
}
}
39 changes: 20 additions & 19 deletions eng/tools/RepoTasks/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,42 @@
using System.IO;
using System.Reflection;

namespace Microsoft.DotNet.Build.Tasks
namespace RepoTasks
{
internal static class FileUtilities
internal static partial class FileUtilities
{
private static readonly HashSet<string> s_assemblyExtensions = new HashSet<string>(
new[] { ".dll", ".exe", ".winmd" },
StringComparer.OrdinalIgnoreCase);

public static Version GetFileVersion(string sourcePath)
{
var fvi = FileVersionInfo.GetVersionInfo(sourcePath);

return fvi != null
? new Version(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart)
: null;
}

private static readonly HashSet<string> _assemblyExtensions = new HashSet<string>(new[] { ".dll", ".exe", ".winmd" }, StringComparer.OrdinalIgnoreCase);

public static Version TryGetAssemblyVersion(string sourcePath)
{
var extension = Path.GetExtension(sourcePath);
if (fvi != null)
{
return new Version(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart);
}

return _assemblyExtensions.Contains(extension)
? GetAssemblyVersion(sourcePath)
: null;
return null;
}

private static Version GetAssemblyVersion(string sourcePath)
public static AssemblyName GetAssemblyName(string path)
{
if (!s_assemblyExtensions.Contains(Path.GetExtension(path)))
{
return null;
}

try
{
return AssemblyName.GetAssemblyName(sourcePath)?.Version;
return AssemblyName.GetAssemblyName(path);
}
catch (BadImageFormatException)
{
// If an .dll file cannot be read, it may be a native .dll which would not have an assembly version.
// Not a valid assembly.
return null;
}
}
}
}
}
3 changes: 1 addition & 2 deletions eng/tools/RepoTasks/GenerateSharedFrameworkDepsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.DotNet.Build.Tasks;
using Microsoft.Extensions.DependencyModel;

namespace RepoTasks
Expand Down Expand Up @@ -61,7 +60,7 @@ private void ExecuteCore()
var filePath = reference.ItemSpec;
var fileName = Path.GetFileName(filePath);
var fileVersion = FileUtilities.GetFileVersion(filePath)?.ToString() ?? string.Empty;
var assemblyVersion = FileUtilities.TryGetAssemblyVersion(filePath);
var assemblyVersion = FileUtilities.GetAssemblyName(filePath)?.Version;
if (assemblyVersion == null)
{
var nativeFile = new RuntimeFile(fileName, null, fileVersion);
Expand Down
1 change: 1 addition & 0 deletions eng/tools/RepoTasks/RepoTasks.tasks
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<UsingTask TaskName="RepoTasks.GenerateGuid" AssemblyFile="$(_RepoTaskAssembly)" Condition="'$(MSBuildRuntimeType)' != 'core'" />
<UsingTask TaskName="RepoTasks.GetMsiProperty" AssemblyFile="$(_RepoTaskAssembly)" Condition="'$(MSBuildRuntimeType)' != 'core'" />
<UsingTask TaskName="RepoTasks.GenerateSharedFrameworkDepsFile" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="RepoTasks.CreateFrameworkListFile" AssemblyFile="$(_RepoTaskAssembly)" />
<UsingTask TaskName="RepoTasks.RemoveSharedFrameworkDependencies" AssemblyFile="$(_RepoTaskAssembly)" />
</Project>
Loading