Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<SystemThreadingAccessControlVersion>7.0.0</SystemThreadingAccessControlVersion>
<!-- Keep toolset versions in sync with dotnet/msbuild and dotnet/sdk -->
<MicrosoftBclAsyncInterfacesToolsetVersion>8.0.0</MicrosoftBclAsyncInterfacesToolsetVersion>
<MicrosoftIoRedistToolsetVersion>6.0.1</MicrosoftIoRedistToolsetVersion>
<SystemBuffersToolsetVersion>4.5.1</SystemBuffersToolsetVersion>
<SystemCollectionsImmutableToolsetVersion>8.0.0</SystemCollectionsImmutableToolsetVersion>
<SystemMemoryToolsetVersion>4.5.5</SystemMemoryToolsetVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void RewriteAppHost(MemoryMappedFile mappedFile, MemoryMappedViewAccessor access
if (File.Exists(appHostDestinationFilePath))
File.Delete(appHostDestinationFilePath);

long appHostSourceLength = new FileInfo(appHostSourceFilePath).Length;
long appHostSourceLength = HostModelUtils.GetFileLength(appHostSourceFilePath);
string destinationFileName = Path.GetFileName(appHostDestinationFilePath);
// Memory-mapped files cannot be resized, so calculate
// the maximum length of the destination file upfront.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public string GenerateBundle(IReadOnlyList<FileSpec> fileSpecs)
// We will memory map a larger file than needed, but we'll take that trade-off.
foreach (var (spec, type) in relativePathToSpec)
{
bundledFilesSize += new FileInfo(spec.SourcePath).Length;
bundledFilesSize += HostModelUtils.GetFileLength(spec.SourcePath);
if (type == FileType.Assembly)
{
// Alignment could be as much as AssemblyAlignment - 1 bytes.
Expand All @@ -314,7 +314,7 @@ public string GenerateBundle(IReadOnlyList<FileSpec> fileSpecs)
{
Directory.CreateDirectory(destinationDirectory);
}
var hostLength = new FileInfo(hostSource).Length;
var hostLength = HostModelUtils.GetFileLength(hostSource);
var bundleManifestLength = Manifest.GetManifestLength(BundleManifest.BundleMajorVersion, relativePathToSpec.Select(x => x.Spec.BundleRelativePath));
long bundleTotalSize = hostLength + bundledFilesSize + bundleManifestLength;
if (_target.IsOSX && _macosCodesign)
Expand Down
11 changes: 11 additions & 0 deletions src/installer/managed/Microsoft.NET.HostModel/HostModelUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
#if NETFRAMEWORK
using Microsoft.IO;
#else
using System.IO;
#endif
using System.Runtime.InteropServices;


namespace Microsoft.NET.HostModel
{
internal static class HostModelUtils
Expand Down Expand Up @@ -32,5 +37,11 @@ public static (int ExitCode, string StdErr) RunCodesign(string args, string appH
return (p.ExitCode, p.StandardError.ReadToEnd());
}
}

public static long GetFileLength(string path)
{
var info = new FileInfo(path);
return ((FileInfo)info.ResolveLinkTarget(true) ?? info).Length;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageDownloadAndReference Include="System.Memory" Version="$(SystemMemoryToolsetVersion)" Folder="lib/net461" />
<PackageDownloadAndReference Include="System.Text.Json" Version="$(SystemTextJsonToolsetVersion)" Folder="lib/net462" />
<PackageDownloadAndReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataToolsetVersion)" Folder="lib/net462" />
<PackageDownloadAndReference Include="Microsoft.IO.Redist" Version="$(MicrosoftIoRedistToolsetVersion)" Folder="lib/net472" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ public void ExactDuplicateEntries()
bundler.BundleManifest.Files.Where(entry => entry.RelativePath.Equals("rel/system.repeat.dll")).Single().Type.Should().Be(FileType.Assembly);
}

[Fact]
public void ResolveLinkTargets()
{
string appPath = Path.Combine(
Path.GetDirectoryName(sharedTestState.App.AppDll),
Path.GetFileNameWithoutExtension(sharedTestState.App.AppDll)
+ ".link" + Path.GetExtension(sharedTestState.App.AppDll));
File.CreateSymbolicLink(appPath, sharedTestState.App.AppDll);
// File specification with duplicate entries with matching source paths
var fileSpecs = new FileSpec[]
{
new FileSpec(Binaries.AppHost.FilePath, BundlerHostName),
new FileSpec(appPath, "rel/app.repeat.dll")
};
Bundler bundler = CreateBundlerInstance();
bundler.GenerateBundle(fileSpecs);
}

[Fact]
public void DuplicateBundleRelativePath_Fails()
{
Expand Down
Loading