@@ -62,14 +62,14 @@ protected override string GetProjectFilePath(string buildArtifactsDirectoryPath)
6262            =>  Path . Combine ( buildArtifactsDirectoryPath ,  "BenchmarkDotNet.Autogenerated.csproj" ) ; 
6363
6464        protected  override  string  GetProjectFilePathForReferences ( string  buildArtifactsDirectoryPath ) 
65-             =>  Path . Combine ( buildArtifactsDirectoryPath ,  "BuildTraversal.buildproj " ) ; 
65+             =>  Path . Combine ( buildArtifactsDirectoryPath ,  "BenchmarkDotNet.Autogenerated.ForReferences.csproj " ) ; 
6666
6767        protected  override  string  GetBinariesDirectoryPath ( string  buildArtifactsDirectoryPath ,  string  configuration ) 
6868            =>  Path . Combine ( buildArtifactsDirectoryPath ,  "bin" ,  configuration ,  TargetFrameworkMoniker ) ; 
6969
7070        [ 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" ) ) 
7373                . Replace ( "$PLATFORM$" ,  buildPartition . Platform . ToConfig ( ) ) 
7474                . Replace ( "$CODEFILENAME$" ,  Path . GetFileName ( artifactsPaths . ProgramCodePath ) ) 
7575                . Replace ( "$CSPROJPATH$" ,  projectFile ) 
@@ -84,35 +84,35 @@ protected override void GenerateProject(BuildPartition buildPartition, Artifacts
8484        { 
8585            var  projectFile  =  GetProjectFilePath ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type ,  logger ) ; 
8686
87-             GenerateBuildTraversalProject ( artifactsPaths ,  projectFile . FullName ) ; 
88- 
8987            var  xmlDoc  =  new  XmlDocument ( ) ; 
9088            xmlDoc . Load ( projectFile . FullName ) ; 
9189            var  ( customProperties ,  sdkName )  =  GetSettingsThatNeedToBeCopied ( xmlDoc ,  projectFile ) ; 
9290
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 ) ; 
10494
10595            File . WriteAllText ( artifactsPaths . ProjectFilePath ,  content ) ; 
10696        } 
10797
108-         protected  void  GenerateBuildTraversalProject ( ArtifactsPaths  artifactsPaths ,  string  projectFilePath ) 
98+         protected  void  GenerateBuildForReferencesProject ( BuildPartition   buildPartition ,   ArtifactsPaths  artifactsPaths ,  string  projectFile ,   string   customProperties ,   string   sdkName ) 
10999        { 
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" ; 
114114
115-             File . WriteAllText ( artifactsPaths . BuildTraversalProjectFilePath ,   content ) ; 
115+             xmlDoc . Save ( artifactsPaths . BuildForReferencesProjectFilePath ) ; 
116116        } 
117117
118118        /// <summary> 
0 commit comments