@@ -62,7 +62,7 @@ protected override string GetProjectFilePath(string buildArtifactsDirectoryPath)
62
62
=> Path . Combine ( buildArtifactsDirectoryPath , "BenchmarkDotNet.Autogenerated.csproj" ) ;
63
63
64
64
protected override string GetProjectFilePathForReferences ( string buildArtifactsDirectoryPath )
65
- => Path . Combine ( buildArtifactsDirectoryPath , "BenchmarkDotNet.Autogenerated.ForReferences.csproj " ) ;
65
+ => Path . Combine ( buildArtifactsDirectoryPath , "BuildTraversal.buildproj " ) ;
66
66
67
67
protected override string GetBinariesDirectoryPath ( string buildArtifactsDirectoryPath , string configuration )
68
68
=> Path . Combine ( buildArtifactsDirectoryPath , "bin" , configuration , TargetFrameworkMoniker ) ;
@@ -71,8 +71,8 @@ protected override string GetIntermediateDirectoryPath(string buildArtifactsDire
71
71
=> Path . Combine ( buildArtifactsDirectoryPath , "obj" , configuration , TargetFrameworkMoniker ) ;
72
72
73
73
[ SuppressMessage ( "ReSharper" , "StringLiteralTypo" ) ] // R# complains about $variables$
74
- private string LoadCsProj ( BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
75
- => new StringBuilder ( ResourceHelper . LoadTemplate ( "CsProj.txt" ) )
74
+ private string LoadCsProj ( string template , BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
75
+ => new StringBuilder ( ResourceHelper . LoadTemplate ( template ) )
76
76
. Replace ( "$PLATFORM$" , buildPartition . Platform . ToConfig ( ) )
77
77
. Replace ( "$CODEFILENAME$" , Path . GetFileName ( artifactsPaths . ProgramCodePath ) )
78
78
. Replace ( "$CSPROJPATH$" , projectFile )
@@ -88,35 +88,35 @@ protected override void GenerateProject(BuildPartition buildPartition, Artifacts
88
88
{
89
89
var projectFile = GetProjectFilePath ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type , logger ) ;
90
90
91
+ GenerateBuildTraversalProject ( artifactsPaths , projectFile . FullName ) ;
92
+
91
93
var xmlDoc = new XmlDocument ( ) ;
92
94
xmlDoc . Load ( projectFile . FullName ) ;
93
95
var ( customProperties , sdkName ) = GetSettingsThatNeedToBeCopied ( xmlDoc , projectFile ) ;
94
96
95
- GenerateBuildForReferencesProject ( buildPartition , artifactsPaths , projectFile . FullName , customProperties , sdkName ) ;
96
-
97
- var content = LoadCsProj ( buildPartition , artifactsPaths , projectFile . FullName , customProperties , sdkName ) ;
97
+ var content = new StringBuilder ( ResourceHelper . LoadTemplate ( "CsProj.txt" ) )
98
+ . Replace ( "$PLATFORM$" , buildPartition . Platform . ToConfig ( ) )
99
+ . Replace ( "$CODEFILENAME$" , Path . GetFileName ( artifactsPaths . ProgramCodePath ) )
100
+ . Replace ( "$CSPROJPATH$" , projectFile . FullName )
101
+ . Replace ( "$TFM$" , TargetFrameworkMoniker )
102
+ . Replace ( "$PROGRAMNAME$" , artifactsPaths . ProgramName )
103
+ . Replace ( "$RUNTIMESETTINGS$" , GetRuntimeSettings ( buildPartition . RepresentativeBenchmarkCase . Job . Environment . Gc , buildPartition . Resolver ) )
104
+ . Replace ( "$COPIEDSETTINGS$" , customProperties )
105
+ . Replace ( "$CONFIGURATIONNAME$" , buildPartition . BuildConfiguration )
106
+ . Replace ( "$SDKNAME$" , sdkName )
107
+ . ToString ( ) ;
98
108
99
109
File . WriteAllText ( artifactsPaths . ProjectFilePath , content ) ;
100
110
}
101
111
102
- protected void GenerateBuildForReferencesProject ( BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
112
+ protected void GenerateBuildTraversalProject ( ArtifactsPaths artifactsPaths , string projectFilePath )
103
113
{
104
- var content = LoadCsProj ( buildPartition , artifactsPaths , projectFile , customProperties , sdkName ) ;
105
-
106
- // We don't include the generated .notcs file when building the reference dlls, only in the final build.
107
- var xmlDoc = new XmlDocument ( ) ;
108
- xmlDoc . Load ( new StringReader ( content ) ) ;
109
- XmlElement projectElement = xmlDoc . DocumentElement ;
110
- projectElement . RemoveChild ( projectElement . SelectSingleNode ( "ItemGroup/Compile" ) . ParentNode ) ;
111
-
112
- var startupObjectElement = projectElement . SelectSingleNode ( "PropertyGroup/StartupObject" ) ;
113
- startupObjectElement . ParentNode . RemoveChild ( startupObjectElement ) ;
114
-
115
- // We need to change the output type to library since we're only compiling for dlls.
116
- var outputTypeElement = projectElement . SelectSingleNode ( "PropertyGroup/OutputType" ) ;
117
- outputTypeElement . InnerText = "Library" ;
114
+ var content = new StringBuilder ( ResourceHelper . LoadTemplate ( "BuildTraversalProj.txt" ) )
115
+ . Replace ( "$CSPROJPATH$" , projectFilePath )
116
+ . Replace ( "$TFM$" , TargetFrameworkMoniker )
117
+ . ToString ( ) ;
118
118
119
- xmlDoc . Save ( artifactsPaths . BuildForReferencesProjectFilePath ) ;
119
+ File . WriteAllText ( artifactsPaths . BuildTraversalProjectFilePath , content ) ;
120
120
}
121
121
122
122
/// <summary>
0 commit comments