Welcome to mirror list, hosted at ThFree Co, Russian Federation.

versioning.targets « eng - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4dacec01a8686b9112847e6dad381b2229fd7653 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<Project>
  <PropertyGroup>
    <GenerateAssemblyInfo Condition="'$(GenerateAssemblyInfo)'==''">true</GenerateAssemblyInfo>
  </PropertyGroup>

  <PropertyGroup Condition="'$(GenerateAssemblyInfo)'=='true'">
    <AssemblyInfoFile Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)_AssemblyInfo.cs</AssemblyInfoFile>
    <AssemblyInfoFile Condition="'$(MSBuildProjectExtension)' == '.vbproj'">$(IntermediateOutputPath)_AssemblyInfo.vb</AssemblyInfoFile>
  </PropertyGroup>

  <!-- Assembly metadata indicating that an assembly is a framework (as opposed to user) assembly:
       Test projects need to not have this because of the way "IsFrameworkAssembly" APIs work to check this. -->
  <ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'" >
    <AssemblyMetadata Include=".NETFrameworkAssembly">
      <Value></Value>
    </AssemblyMetadata>
    <AssemblyMetadata Include="Serviceable">
      <Value>True</Value>
    </AssemblyMetadata>
    <AssemblyMetadata Include="PreferInbox">
      <Value>True</Value>
    </AssemblyMetadata>
    <AssemblyMetadata Include="IsTrimmable" Condition="'$(SetIsTrimmable)' != 'false'">
      <Value>True</Value>
    </AssemblyMetadata>
  </ItemGroup>

  <PropertyGroup Condition="'$(TargetsAnyOS)' == 'true' and !$(TargetFrameworks.Contains('$(TargetFramework)-Browser'))">
      <CrossPlatformAndHasNoBrowserTarget>true</CrossPlatformAndHasNoBrowserTarget>
  </PropertyGroup>

  <!-- Enables warnings for Android, iOS, tvOS and macCatalyst for all builds -->
  <ItemGroup>
    <SupportedPlatform Include="Android" />
    <SupportedPlatform Include="iOS" />
    <SupportedPlatform Include="tvOS" />
    <SupportedPlatform Include="macCatalyst" />
  </ItemGroup>

  <!-- Enables browser warnings for cross platform or Browser targeted builds -->
  <ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(CrossPlatformAndHasNoBrowserTarget)' == 'true') and '$(IsTestProject)' != 'true'">
    <SupportedPlatform Include="browser"/>
  </ItemGroup>

  <!-- Add target platforms into MSBuild SupportedPlatform list -->
  <ItemGroup Condition="'$(TargetsAnyOS)' != 'true' and '$(IsTestProject)' != 'true'">
    <SupportedPlatform Condition="'$(Targetsillumos)' == 'true'" Include="illumos"/>
    <SupportedPlatform Condition="'$(TargetsSolaris)' == 'true'" Include="Solaris"/>
    <SupportedPlatform Condition="'$(TargetstvOS)' == 'true'" Include="tvOS"/>
    <SupportedPlatform Condition="'$(TargetsUnix)' == 'true'" Include="Unix"/>
  </ItemGroup>

  <!-- Adds UnsupportedOSPlatform and SupportedOSPlatform attributes to the assembly when:
      * This isn't a test project
      * This is a cross-platform target
      * The build isn't targeting .NET Framework
    -->
  <Target Name="AddOSPlatformAttributes" BeforeTargets="GenerateAssemblyInfo" AfterTargets="PrepareForBuild"
    Condition="'$(TargetsAnyOS)' == 'true' and '$(IsTestProject)' != 'true' and '$(TargetFrameworkIdentifier)' != '.NETFramework'">
    <!-- Defensively de-dupe the values -->
    <ItemGroup>
      <_unsupportedOSPlatforms Include="$(UnsupportedOSPlatforms)" />
      <_supportedOSPlatforms Include="$(SupportedOSPlatforms)" />
    </ItemGroup>

    <ItemGroup Condition="'@(_unsupportedOSPlatforms)' != ''">
      <!-- Add the assembly attribute -->
      <AssemblyAttribute Include="System.Runtime.Versioning.UnsupportedOSPlatform">
        <_Parameter1>%(_unsupportedOSPlatforms.Identity)</_Parameter1>
      </AssemblyAttribute>

      <!-- Ensure this platform is included in the platforms enabled for the CA1416 analyzer -->
      <SupportedPlatform Include="%(_unsupportedOSPlatforms.Identity)" />
    </ItemGroup>

    <ItemGroup Condition="'@(_supportedOSPlatforms)' != ''">
      <!-- Add the assembly attribute -->
      <AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform">
        <_Parameter1>%(_supportedOSPlatforms.Identity)</_Parameter1>
      </AssemblyAttribute>

      <!-- Ensure this platform is included in the platforms enabled for the CA1416 analyzer -->
      <SupportedPlatform Include="%(_supportedOSPlatforms.Identity)" />
    </ItemGroup>
  </Target>

  <!-- Add PlatformNeutralAssembly property for targeted builds of cross platform assemblies -->
  <ItemGroup Condition="'$(TargetsAnyOS)' != 'true' and '$(IsTestProject)' != 'true' and '@(SupportedOSPlatforms)' == ''">
    <CompilerVisibleProperty Include="PlatformNeutralAssembly" />
  </ItemGroup>

  <PropertyGroup>
    <!-- corefx has never generated these attributes so don't let the SDK generate them -->
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>

    <!-- corefx has always added a description set to assembly name so include that here -->
    <Description Condition="'$(Description)' == ''">$(AssemblyName)</Description>
  </PropertyGroup>

  <Target Name="_ComputeBuildToolsAssemblyInfoAttributes"
          BeforeTargets="GetAssemblyAttributes">
    <ItemGroup>
      <AssemblyAttribute Include="System.Reflection.AssemblyDefaultAliasAttribute">
        <_Parameter1>$(AssemblyName)</_Parameter1>
      </AssemblyAttribute>

      <AssemblyAttribute Include="System.Resources.NeutralResourcesLanguage" Condition="'@(EmbeddedResource)' != '' and '$(IsSourceProject)' == 'true'">
        <_Parameter1>en-US</_Parameter1>
      </AssemblyAttribute>

      <AssemblyAttribute Include="System.Reflection.AssemblyMetadata"
                         Condition="'@(AssemblyMetadata)' != ''">
        <_Parameter1>%(AssemblyMetadata.Identity)</_Parameter1>
        <_Parameter2>%(AssemblyMetadata.Value)</_Parameter2>
      </AssemblyAttribute>
    </ItemGroup>
  </Target>

  <!-- Work around https://github.com/Microsoft/msbuild/issues/3412 by writing the non-string assembly attributes manually -->
  <!-- Note: ReferenceAssemblies.targets still uses @(AssemblyInfoLines) as well. So if you remove this, those need to migrate too. -->
  <Target Name="_WriteNonStringAssemblyInfoAttributes"
          DependsOnTargets="ResolveReferences"
          AfterTargets="CoreGenerateAssemblyInfo"
          BeforeTargets="BeforeCompile;CoreCompile"
          Inputs="$(MSBuildProjectFile)"
          Outputs="$(AssemblyInfoFile)">

    <!-- We want to apply the IncludeDllSafeSearchPathAttribute on all source assemblies that may contain DllImport -->
    <PropertyGroup Condition="'$(IncludeDllSafeSearchPathAttribute)'=='' and '$(IsSourceProject)'== 'true'">
      <IncludeDllSafeSearchPathAttribute>false</IncludeDllSafeSearchPathAttribute>
      <!-- We don't need to include it by default. -->
      <IncludeDllSafeSearchPathAttribute Condition="'%(ReferencePath.Filename)' == 'System.Runtime.InteropServices'">true</IncludeDllSafeSearchPathAttribute>
      <IncludeDllSafeSearchPathAttribute Condition="'%(ReferencePath.Filename)' == 'System.Private.CoreLib'">true</IncludeDllSafeSearchPathAttribute>
      <IncludeDllSafeSearchPathAttribute Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard' and '%(ReferencePath.Filename)' == 'netstandard'">true</IncludeDllSafeSearchPathAttribute>
      <IncludeDllSafeSearchPathAttribute Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '%(ReferencePath.Filename)' == 'mscorlib'">true</IncludeDllSafeSearchPathAttribute>
    </PropertyGroup>

    <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
      <AssemblyInfoLines Condition="'$(CLSCompliant)'=='true'" Include="[assembly:System.CLSCompliant(true)]" />

      <AssemblyInfoLines Condition="'$(IncludeDllSafeSearchPathAttribute)'=='true'"
        Include="[assembly: System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute(System.Runtime.InteropServices.DllImportSearchPath.AssemblyDirectory | System.Runtime.InteropServices.DllImportSearchPath.System32)]" />
    </ItemGroup>

    <ItemGroup Condition="'$(MSBuildProjectExtension)' == '.vbproj'">
      <AssemblyInfoLines Condition="'$(CLSCompliant)'=='true'" Include="&lt;Assembly:System.CLSCompliant(True)&gt;" />

      <AssemblyInfoLines Condition="'$(IncludeDllSafeSearchPathAttribute)'=='true'"
        Include="&lt;Assembly:System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute(System.Runtime.InteropServices.DllImportSearchPath.AssemblyDirectory Or System.Runtime.InteropServices.DllImportSearchPath.System32)&gt;" />
    </ItemGroup>

    <WriteLinesToFile File="$(AssemblyInfoFile)"
                      Lines="@(AssemblyInfoLines)"
                      Condition="'@(AssemblyInfoLines)' != ''"
                      Overwrite="true" />

    <ItemGroup Condition="'@(AssemblyInfoLines)' != ''">
      <Compile Include="$(AssemblyInfoFile)" />
      <FileWrites Include="$(AssemblyInfoFile)" />
    </ItemGroup>
  </Target>

  <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>

  <!-- Removes assembly level attributes from test projects. -->
  <Target Name="RemoveSupportedOSPlatformAttributeFromTestProjects" AfterTargets="GetAssemblyAttributes" Condition="'$(IsTestProject)' == 'true'">
    <ItemGroup>
      <AssemblyAttribute Remove="System.Runtime.Versioning.SupportedOSPlatformAttribute" />
      <AssemblyAttribute Remove="System.Runtime.Versioning.TargetPlatformAttribute" />
    </ItemGroup>
  </Target>

</Project>