Update expected SDK version test to work with multiple stages

This commit is contained in:
Daniel Plaisted 2017-08-11 08:37:31 -07:00
parent 12f8c2377f
commit e4777c0b91
2 changed files with 29 additions and 11 deletions

View file

@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Tests
[Fact]
public void VersionCommandDisplaysCorrectVersion()
{
var versionFilePath = Path.Combine(AppContext.BaseDirectory, ".version");
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "ExpectedSdkVersion.txt");
var version = GetVersionFromFile(versionFilePath);
CommandResult result = new DotnetCommand()
@ -31,14 +31,8 @@ namespace Microsoft.DotNet.Tests
{
using (var reader = new StreamReader(File.OpenRead(versionFilePath)))
{
SkipCommit(reader);
return reader.ReadLine();
}
}
private void SkipCommit(StreamReader reader)
{
reader.ReadLine();
}
}
}

View file

@ -22,11 +22,35 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="$(SdkOutputDirectory)\.version">
<Link>.version</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="WriteExpectedVersion"
BeforeTargets="BeforeBuild"
DependsOnTargets="PrepareForBuild">
<PropertyGroup>
<ExpectedVersionFileInIntermediateFolder>$(IntermediateOutputPath)ExpectedSdkVersion.txt</ExpectedVersionFileInIntermediateFolder>
<VersionFileContent>$(SdkVersion)</VersionFileContent>
<ExistingVersionFileContent Condition=" Exists('$(ExpectedVersionFileInIntermediateFolder)') ">
$([System.IO.File]::ReadAllText($(ExpectedVersionFileInIntermediateFolder)))
</ExistingVersionFileContent>
<ShouldOverwriteVersionFile>false</ShouldOverwriteVersionFile>
<ShouldOverwriteVersionFile
Condition=" '$(ExistingVersionFileContent.Trim())' != '$(VersionFileContent.Trim())' ">true</ShouldOverwriteVersionFile>
</PropertyGroup>
<WriteLinesToFile File="$(ExpectedVersionFileInIntermediateFolder)"
Lines="$(VersionFileContent)"
Condition=" '$(ShouldOverwriteVersionFile)' == 'true' "
Overwrite="true" />
<ItemGroup>
<Content Include="$(ExpectedVersionFileInIntermediateFolder)" CopyToOutputDirectory="PreserveNewest" />
<FileWrites Include="$(ExpectedVersionFileInIntermediateFolder)" />
</ItemGroup>
</Target>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />