@@ -20,6 +20,7 @@ namespace BenchmarkDotNet.Toolchains.NativeAot
20
20
public class Generator : CsProjGenerator
21
21
{
22
22
internal const string NativeAotNuGetFeed = "nativeAotNuGetFeed" ;
23
+ internal const string GeneratedRdXmlFileName = "bdn_generated.rd.xml" ;
23
24
24
25
internal Generator ( string ilCompilerVersion , bool useCppCodeGenerator ,
25
26
string runtimeFrameworkVersion , string targetFrameworkMoniker , string cliPath ,
@@ -150,7 +151,7 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif
150
151
<ProjectReference Include=""{ GetProjectFilePath ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type , logger ) . FullName } "" />
151
152
</ItemGroup>
152
153
<ItemGroup>
153
- <RdXmlFile Include=""rd.xml"" />
154
+ { string . Join ( Environment . NewLine , GetRdXmlFiles ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type , logger ) . Select ( file => $ " <RdXmlFile Include=\" { file } \" />" ) ) }
154
155
</ItemGroup>
155
156
</Project>" ;
156
157
@@ -185,7 +186,7 @@ private string GenerateProjectForLocalBuild(BuildPartition buildPartition, Artif
185
186
<ProjectReference Include=""{ GetProjectFilePath ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type , logger ) . FullName } "" />
186
187
</ItemGroup>
187
188
<ItemGroup>
188
- <RdXmlFile Include=""rd.xml"" />
189
+ { string . Join ( Environment . NewLine , GetRdXmlFiles ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type , logger ) . Select ( file => $ " <RdXmlFile Include=\" { file } \" />" ) ) }
189
190
</ItemGroup>
190
191
</Project>" ;
191
192
@@ -203,6 +204,23 @@ private string GetTrimmingSettings()
203
204
return sb . ToString ( ) ;
204
205
}
205
206
207
+ public IEnumerable < string > GetRdXmlFiles ( Type benchmarkTarget , ILogger logger )
208
+ {
209
+ var projectFile = GetProjectFilePath ( benchmarkTarget , logger ) ;
210
+ var projectFileFolder = projectFile . DirectoryName ;
211
+ yield return GeneratedRdXmlFileName ;
212
+ var rdXml = Path . Combine ( projectFileFolder , "rd.xml" ) ;
213
+ if ( File . Exists ( rdXml ) )
214
+ {
215
+ yield return rdXml ;
216
+ }
217
+
218
+ foreach ( var item in Directory . GetFiles ( projectFileFolder , "*.rd.xml" ) )
219
+ {
220
+ yield return item ;
221
+ }
222
+ }
223
+
206
224
/// <summary>
207
225
/// mandatory to make it possible to call GC.GetAllocatedBytesForCurrentThread() using reflection (not part of .NET Standard)
208
226
/// </summary>
@@ -226,7 +244,7 @@ private void GenerateReflectionFile(ArtifactsPaths artifactsPaths)
226
244
227
245
string directoryName = Path . GetDirectoryName ( artifactsPaths . ProjectFilePath ) ;
228
246
if ( directoryName != null )
229
- File . WriteAllText ( Path . Combine ( directoryName , "rd.xml" ) , content ) ;
247
+ File . WriteAllText ( Path . Combine ( directoryName , GeneratedRdXmlFileName ) , content ) ;
230
248
else
231
249
throw new InvalidOperationException ( $ "Can't get directory of projectFilePath ('{ artifactsPaths . ProjectFilePath } ')") ;
232
250
}
0 commit comments