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
10 changes: 9 additions & 1 deletion eng/versioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,18 @@
</Target>

<Target Name="GenerateNativeSourcelinkFile"
DependsOnTargets="GenerateSourceLinkFile"
Condition="'$(DisableSourceLink)' != 'true'"
DependsOnTargets="_CopyGeneratedSourcelinkFile;_VerifyNativeSourceLinkFileExists" />

<Target Name="_CopyGeneratedSourcelinkFile"
DependsOnTargets="GenerateSourceLinkFile"
Inputs="$(SourceLink)" Outputs="$(NativeSourceLinkFile)">
<Error Condition="'$(NativeSourceLinkFile)' == ''" Text="Please set NativeSourceLinkFile to forward appropriate information for sourcelink."/>
<Copy SourceFiles="$(SourceLink)" DestinationFiles="$(NativeSourceLinkFile)" />
</Target>

<Target Name="_VerifyNativeSourceLinkFileExists"
Condition="'$(VerifySourceLinkFileExists)' == true">
<Error Condition="!Exists('$(NativeSourceLinkFile)')" Text="Native SourceLink file could not be made available to the native build. Ensure that $(MSBuildProjectName) ran the sourcelink targets."/>
</Target>
</Project>
14 changes: 13 additions & 1 deletion src/coreclr/runtime-prereqs.proj
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.Build.NoTargets" />
<PropertyGroup>
<NativeVersionFile Condition="$([MSBuild]::IsOsPlatform(Windows))">$(ArtifactsObjDir)_version.h</NativeVersionFile>
<NativeVersionFile Condition="!$([MSBuild]::IsOsPlatform(Windows))">$(ArtifactsObjDir)_version.c</NativeVersionFile>
<RuntimeVersionFile>$(ArtifactsObjDir)runtime_version.h</RuntimeVersionFile>
<NativeSourceLinkFile>$(ArtifactsObjDir)native.sourcelink.json</NativeSourceLinkFile>
<VerifySourceLinkFileExists>false</VerifySourceLinkFileExists>
<VerifySourceLinkFileExists Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</VerifySourceLinkFileExists>
<AssemblyName>.NET Runtime</AssemblyName>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
<Import Project="$(RepositoryEngineeringDir)nativepgo.targets" />

<Target Name="BuildPrereqs" BeforeTargets="Build" DependsOnTargets="GenerateRuntimeVersionFile;GenerateNativeSourcelinkFile;OutputPgoPathForCI" />
<Import Project="Sdk.targets" Sdk="Microsoft.Build.NoTargets" />
<!--
This is relatively ugly. The NoTargets SDK sets DebugType=None, but that makes it such that the sourcelink targets
don't run, and we wouldn't generate the sourcelink file for native compilation. It would be better if we could call
the target directly and have it generate the file, but it's guarded by this property anyway...
Comment on lines +19 to +21
Copy link
Copy Markdown
Member

@ViktorHofer ViktorHofer May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider submitting a change to https://github.com/dotnet/sourcelink to allow overriding this setting via a custom property?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-->
<PropertyGroup>
<DebugType>Portable</DebugType>
</PropertyGroup>
</Project>