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