Skip to content

Commit 7c58b8b

Browse files
authored
Add .version file to shared framework zip (#21587)
* Add .version file to shared framework zip * Fix test * Test for proper version file depending on env
1 parent 9a5d3c7 commit 7c58b8b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
6767
<!-- There is no way to suppress the .dev.runtimeconfig.json generation. -->
6868
<ProjectRuntimeConfigDevFilePath>$(IntermediateOutputPath)ignoreme.dev.runtimeconfig.json</ProjectRuntimeConfigDevFilePath>
6969

70-
<VersionFileIntermediateOutputPath>$(IntermediateOutputPath)$(SharedFxName).versions.txt</VersionFileIntermediateOutputPath>
70+
<VersionTxtFileIntermediateOutputPath>$(IntermediateOutputPath)$(SharedFxName).versions.txt</VersionTxtFileIntermediateOutputPath>
71+
<DotVersionFileIntermediateOutputPath>$(IntermediateOutputPath).version</DotVersionFileIntermediateOutputPath>
7172

7273
<!-- The project representing the shared framework doesn't produce a .NET assembly or symbols. -->
7374
<DebugType>none</DebugType>
@@ -259,7 +260,12 @@ This package is an internal implementation of the .NET Core SDK and is not meant
259260
</ItemGroup>
260261

261262
<WriteLinesToFile
262-
File="$(VersionFileIntermediateOutputPath)"
263+
File="$(VersionTxtFileIntermediateOutputPath)"
264+
Lines="@(VersionLines)"
265+
Overwrite="true" />
266+
267+
<WriteLinesToFile
268+
File="$(DotVersionFileIntermediateOutputPath)"
263269
Lines="@(VersionLines)"
264270
Overwrite="true" />
265271
</Target>
@@ -402,7 +408,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
402408

403409
<Target Name="_ResolveSharedFrameworkContent" DependsOnTargets="ResolveReferences;Crossgen">
404410
<ItemGroup>
405-
<SharedFxContent Include="$(VersionFileIntermediateOutputPath)" />
411+
<SharedFxContent Include="$(DotVersionFileIntermediateOutputPath)" />
406412
<SharedFxContent Include="$(ProjectDepsFilePath)" />
407413
<SharedFxContent Include="$(ProjectRuntimeConfigFilePath)" />
408414
<SharedFxContent Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' != '.pdb'" />
@@ -501,7 +507,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
501507
BeforeTargets="_GetPackageFiles">
502508

503509
<ItemGroup>
504-
<None Include="$(VersionFileIntermediateOutputPath)" Pack="true" PackagePath="." />
510+
<None Include="$(VersionTxtFileIntermediateOutputPath)" Pack="true" PackagePath="." />
505511
</ItemGroup>
506512
</Target>
507513

src/Framework/test/SharedFxTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SharedFxTests
1515
{
1616
private readonly string _expectedTfm;
1717
private readonly string _expectedRid;
18+
private readonly string _expectedVersionFileName;
1819
private readonly string _sharedFxRoot;
1920
private readonly ITestOutputHelper _output;
2021

@@ -26,6 +27,7 @@ public SharedFxTests(ITestOutputHelper output)
2627
_sharedFxRoot = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH"))
2728
? Path.Combine(TestData.GetTestDataValue("SharedFrameworkLayoutRoot"), "shared", TestData.GetTestDataValue("RuntimePackageVersion"))
2829
: Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH");
30+
_expectedVersionFileName = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH")) ? ".version" : "Microsoft.AspNetCore.App.versions.txt";
2931
}
3032

3133
[Fact]
@@ -133,7 +135,7 @@ public void ItContainsValidDepsJson()
133135
[Fact]
134136
public void ItContainsVersionFile()
135137
{
136-
var versionFile = Path.Combine(_sharedFxRoot, "Microsoft.AspNetCore.App.versions.txt");
138+
var versionFile = Path.Combine(_sharedFxRoot, _expectedVersionFileName);
137139
AssertEx.FileExists(versionFile);
138140
var lines = File.ReadAllLines(versionFile);
139141
Assert.Equal(2, lines.Length);

0 commit comments

Comments
 (0)