-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathnative-prereqs.proj
72 lines (58 loc) · 3.11 KB
/
native-prereqs.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.Build.NoTargets" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>false</SkipGetTargetFrameworkProperties>
</PropertyGroup>
<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>
<AssemblyName>.NET Diagnostics</AssemblyName>
</PropertyGroup>
<Target Name="GenerateRuntimeVersionFile"
DependsOnTargets="GenerateNativeVersionFile">
<PropertyGroup>
<RuntimeVersionFile Condition="'$(RuntimeVersionFile)' == ''">$(ArtifactsObjDir)runtime_version.h</RuntimeVersionFile>
<_RuntimeVersionFileContents>
<![CDATA[
#define RuntimeAssemblyMajorVersion $(MajorVersion)
#define RuntimeAssemblyMinorVersion $(MinorVersion)
#define RuntimeFileMajorVersion $(FileVersion.Split('.')[0])
#define RuntimeFileMinorVersion $(FileVersion.Split('.')[1])
#define RuntimeFileBuildVersion $(FileVersion.Split('.')[2])
#define RuntimeFileRevisionVersion $(FileVersion.Split('.')[3])
#define RuntimeProductMajorVersion $(Version.Split(".-")[0])
#define RuntimeProductMinorVersion $(Version.Split(".-")[1])
#define RuntimeProductPatchVersion $(Version.Split(".-")[2])
#define RuntimeProductVersion $(Version)
]]>
</_RuntimeVersionFileContents>
</PropertyGroup>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(RuntimeVersionFile)))" />
<WriteLinesToFile
File="$(RuntimeVersionFile)"
Lines="$(_RuntimeVersionFileContents)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
<Target Name="GenerateNativeSourcelinkFile"
Condition="'$(EnableSourceLink)' == 'true'"
DependsOnTargets="_CreateIntermediateOutputPath;_CopyGeneratedSourcelinkFile;_VerifyNativeSourceLinkFileExists" />
<Target Name="_CreateIntermediateOutputPath">
<MakeDir Directories="$(IntermediateOutputPath)" />
</Target>
<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>
<Target Name="BuildPrereqs" BeforeTargets="Build" DependsOnTargets="GenerateRuntimeVersionFile" />
<Import Project="Sdk.targets" Sdk="Microsoft.Build.NoTargets" />
</Project>