Skip to content

Commit

Permalink
Force specific SDK and runtime versions. (#377)
Browse files Browse the repository at this point in the history
Addresses #373
  • Loading branch information
johnstairs authored Mar 7, 2019
1 parent 6534edc commit e8faf39
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<HighEntropyVA>true</HighEntropyVA>
<EnableSourceLink Condition="$([MSBuild]::IsOSPlatform('osx'))">false</EnableSourceLink>
<EnableSourceControlManagerQueries>$(EnableSourceLink)</EnableSourceControlManagerQueries>
<!--This will target the latest patch release of the runtime released with the current SDK. -->
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<PropertyGroup Condition=" '$(EnableSourceLink)' == 'true' ">
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ phases:

- task: DotNetCoreInstaller@0
inputs:
version: '2.2.101'
version: '2.2.103'

- script: dotnet build --configuration $(buildConfiguration) --version-suffix $(build.buildNumber) /warnaserror
displayName: 'dotnet build $(buildConfiguration)'
Expand All @@ -32,4 +32,4 @@ phases:
arguments: '--configuration $(buildConfiguration)'

- ${{ if eq(parameters.packageArtifacts, 'true') }}:
- template: package.yml
- template: package.yml
2 changes: 1 addition & 1 deletion build/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ steps:
inputs:
command: publish
projects: '**/Microsoft.Health.Fhir.Web.csproj'
arguments: '--output $(build.artifactStagingDirectory)/web --configuration $(buildConfiguration) --no-build'
arguments: '--runtime win10-x64 --output $(build.artifactStagingDirectory)/web --configuration $(buildConfiguration) --version-suffix $(build.buildnumber)'
publishWebProjects: false

- task: DotNetCoreCLI@2
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.101"
"version": "2.2.103"
}
}
}
3 changes: 3 additions & 0 deletions src/Microsoft.Health.Fhir.Web/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"applyPatches": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,27 @@
</None>
</ItemGroup>
<Import Project="Microsoft.AspNetCore.Mvc.Testing.targets" />

<Target Name="VerifyExactSdkVersion" BeforeTargets="Build">

<!--
Verify that the we are compiling with the exact version of the SDK that is specified in the global.json file.
If the version specified in the file is not installed on the system, dotnet uses the latest installed version instead.
We want to avoid that behavior because new SDK versions by default target the runtime version it is released with,
so the runtime behavior could be different depending on what SDK versions were installed on the machine that compiled
the code.
-->

<PropertyGroup>
<GlobalJsonPath>$([MSBuild]::GetPathOfFileAbove(global.json))</GlobalJsonPath>
<GlobalJsonContent>$([System.IO.File]::ReadAllText($(GlobalJsonPath)))</GlobalJsonContent>
<ParsedSdkVersion><![CDATA[$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '"version"\s*:\s*"(\d+.\d+.\d+)"').Groups[1].Value)]]></ParsedSdkVersion>
</PropertyGroup>

<Error Condition="$(NETCoreSdkVersion) != $(ParsedSdkVersion)"
Text="The .NET SDK version required by $(GlobalJsonPath) is $(ParsedSdkVersion) but that version does not seem to be installed. In order to ensure consistent behavior, please install version $(ParsedSdkVersion) of the .NET SDK from https://dotnet.microsoft.com/download." />
</Target>

<Target Name="AddRuntimeConfigFileToBuiltProjectOutputGroupOutput" Condition=" '$(GenerateRuntimeConfigurationFiles)' == 'true'" BeforeTargets="BuiltProjectOutputGroup">
<ItemGroup>
<BuiltProjectOutputGroupOutput Include="$(ProjectRuntimeConfigFilePath)" FinalOutputPath="$(ProjectRuntimeConfigFilePath)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"applyPatches": false
}

0 comments on commit e8faf39

Please sign in to comment.