[Static Web Assets] Removes support for embedding the development manifest

* Stops embedding the manifest in favor of using a file copied to the output folder.
\n\nCommit migrated from 4c65b1947f
This commit is contained in:
Javier Calvarro Nelson 2019-06-05 13:40:11 -07:00 committed by GitHub
parent 48eeaefc1e
commit 22f593b796
3 changed files with 25 additions and 77 deletions

View File

@ -182,11 +182,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- This is the list of inputs that will be used for generating the manifest used during development. -->
<ItemGroup>
<EmbeddedResource Condition="'@(_ExternalStaticWebAsset->Count())' != '0'"
Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)"
LogicalName="Microsoft.AspNetCore.StaticWebAssets.xml" />
<!-- Include it as content as we plan to avoid using an embedded file for the manifest -->
<Content
Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)"
Condition="'@(_ExternalStaticWebAsset->Count())' != '0'"

View File

@ -345,58 +345,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
}
}
public static Stream ContainsEmbeddedResource(string assemblyPath, string resourceName)
{
var stream = ExtractEmbeddedResource(assemblyPath, resourceName);
Assert.NotNull(stream);
return stream;
}
public static void DoesNotContainEmbeddedResource(string assemblyPath, string resourceName)
{
var stream = ExtractEmbeddedResource(assemblyPath, resourceName);
Assert.Null(stream);
}
private static Stream ExtractEmbeddedResource(string path, string expectedResourceName)
{
using (var peStream = File.OpenRead(path))
{
using (var peReader = new PEReader(peStream))
{
var mdReader = peReader.GetMetadataReader();
foreach (var resourceHandle in mdReader.ManifestResources)
{
var resource = mdReader.GetManifestResource(resourceHandle);
if (!resource.Implementation.IsNil)
{
continue; // resource is not embedded.
}
var resourceName = mdReader.GetString(resource.Name);
if (!string.Equals(expectedResourceName, resourceName))
{
continue;
}
// We are not taking resource.Offset into account here.
// We currently only have the casuistic that we are embedding a single resource.
// If that changes we'll have to change this test code, but as its hard we won't do it for now.
var resourcesSection = peReader.GetSectionData(peReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);
var resourcesReader = resourcesSection.GetReader();
var resourceSizeInBytes = resourcesReader.ReadInt32();
var resourceBytes = resourcesReader.ReadBytes(resourceSizeInBytes);
return new MemoryStream(resourceBytes, writable: false);
}
}
}
return null;
}
public static void NuspecContains(MSBuildResult result, string nuspecPath, string expected)
{
if (result == null)

View File

@ -54,14 +54,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
}
var path = Assert.FileExists(result, OutputPath, "AppWithPackageAndP2PReference.dll");
var assembly = Assert.ContainsEmbeddedResource(path, "Microsoft.AspNetCore.StaticWebAssets.xml");
using (var reader = new StreamReader(assembly))
{
var data = await reader.ReadToEndAsync();
Output.WriteLine("Manifest:");
Output.WriteLine(data);
Assert.Equal(expectedManifest, data);
}
var manifest = Assert.FileExists(result, OutputPath, "AppWithPackageAndP2PReference.StaticWebAssets.xml");
var data = File.ReadAllText(manifest);
Assert.Equal(expectedManifest, data);
}
[Fact]
@ -124,7 +119,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.StaticWebAssets.xml");
var path = Assert.FileExists(result, OutputPath, "SimpleMvc.dll");
Assert.DoesNotContainEmbeddedResource(path, "SimpleMvc.StaticWebAssets.xml");
}
[Fact]
@ -190,12 +184,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
}
var path = Assert.FileExists(result, OutputPath, "AppWithPackageAndP2PReference.dll");
var assembly = Assert.ContainsEmbeddedResource(path, "Microsoft.AspNetCore.StaticWebAssets.xml");
using (var reader = new StreamReader(assembly))
{
var data = reader.ReadToEnd();
Assert.Equal(expectedManifest, data);
}
var manifest = Assert.FileExists(result, OutputPath, "AppWithPackageAndP2PReference.StaticWebAssets.xml");
var data = File.ReadAllText(manifest);
Assert.Equal(expectedManifest, data);
}
[Fact]
@ -274,6 +265,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
public class PackageTestProjectsFixture
{
private const int MaxPackRetries = 3;
private const int MaxPackTimeoutInMinutes = 5;
private bool _packed;
internal async Task PackAsync(ITestOutputHelper output)
@ -305,12 +299,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
RedirectStandardError = true
};
var result = await MSBuildProcessManager.RunProcessCoreAsync(
psi,
TimeSpan.FromMinutes(2));
for (int i = 0; i < MaxPackRetries; i++)
{
try
{
var result = await MSBuildProcessManager.RunProcessCoreAsync(
psi,
TimeSpan.FromMinutes(MaxPackTimeoutInMinutes));
output.WriteLine(result.Output);
Assert.Equal(0, result.ExitCode);
output.WriteLine(result.Output);
Assert.Equal(0, result.ExitCode);
break;
}
catch
{
await Task.Delay(1000);
}
}
}
_packed = true;