@@ -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 , "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 ) ;
@@ -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 ( string template , BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
75
- => new StringBuilder ( ResourceHelper . LoadTemplate ( template ) )
74
+ private string LoadCsProj ( BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
75
+ => new StringBuilder ( ResourceHelper . LoadTemplate ( "CsProj.txt" ) )
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
-
93
91
var xmlDoc = new XmlDocument ( ) ;
94
92
xmlDoc . Load ( projectFile . FullName ) ;
95
93
var ( customProperties , sdkName ) = GetSettingsThatNeedToBeCopied ( xmlDoc , projectFile ) ;
96
94
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 ( ) ;
95
+ GenerateBuildForReferencesProject ( buildPartition , artifactsPaths , projectFile . FullName , customProperties , sdkName ) ;
96
+
97
+ var content = LoadCsProj ( buildPartition , artifactsPaths , projectFile . FullName , customProperties , sdkName ) ;
108
98
109
99
File . WriteAllText ( artifactsPaths . ProjectFilePath , content ) ;
110
100
}
111
101
112
- protected void GenerateBuildTraversalProject ( ArtifactsPaths artifactsPaths , string projectFilePath )
102
+ protected void GenerateBuildForReferencesProject ( BuildPartition buildPartition , ArtifactsPaths artifactsPaths , string projectFile , string customProperties , string sdkName )
113
103
{
114
- var content = new StringBuilder ( ResourceHelper . LoadTemplate ( "BuildTraversalProj.txt" ) )
115
- . Replace ( "$CSPROJPATH$" , projectFilePath )
116
- . Replace ( "$TFM$" , TargetFrameworkMoniker )
117
- . ToString ( ) ;
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" ;
118
118
119
- File . WriteAllText ( artifactsPaths . BuildTraversalProjectFilePath , content ) ;
119
+ xmlDoc . Save ( artifactsPaths . BuildForReferencesProjectFilePath ) ;
120
120
}
121
121
122
122
/// <summary>
0 commit comments