@@ -62,7 +62,7 @@ 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 ) ; 
@@ -71,8 +71,8 @@ protected override string GetIntermediateDirectoryPath(string buildArtifactsDire
7171            =>  Path . Combine ( buildArtifactsDirectoryPath ,  "obj" ,  configuration ,  TargetFrameworkMoniker ) ; 
7272
7373        [ 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" ) ) 
7676                . Replace ( "$PLATFORM$" ,  buildPartition . Platform . ToConfig ( ) ) 
7777                . Replace ( "$CODEFILENAME$" ,  Path . GetFileName ( artifactsPaths . ProgramCodePath ) ) 
7878                . Replace ( "$CSPROJPATH$" ,  projectFile ) 
@@ -88,35 +88,35 @@ protected override void GenerateProject(BuildPartition buildPartition, Artifacts
8888        { 
8989            var  projectFile  =  GetProjectFilePath ( buildPartition . RepresentativeBenchmarkCase . Descriptor . Type ,  logger ) ; 
9090
91-             GenerateBuildTraversalProject ( artifactsPaths ,  projectFile . FullName ) ; 
92- 
9391            var  xmlDoc  =  new  XmlDocument ( ) ; 
9492            xmlDoc . Load ( projectFile . FullName ) ; 
9593            var  ( customProperties ,  sdkName )  =  GetSettingsThatNeedToBeCopied ( xmlDoc ,  projectFile ) ; 
9694
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 ) ; 
10898
10999            File . WriteAllText ( artifactsPaths . ProjectFilePath ,  content ) ; 
110100        } 
111101
112-         protected  void  GenerateBuildTraversalProject ( ArtifactsPaths  artifactsPaths ,  string  projectFilePath ) 
102+         protected  void  GenerateBuildForReferencesProject ( BuildPartition   buildPartition ,   ArtifactsPaths  artifactsPaths ,  string  projectFile ,   string   customProperties ,   string   sdkName ) 
113103        { 
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" ; 
118118
119-             File . WriteAllText ( artifactsPaths . BuildTraversalProjectFilePath ,   content ) ; 
119+             xmlDoc . Save ( artifactsPaths . BuildForReferencesProjectFilePath ) ; 
120120        } 
121121
122122        /// <summary> 
0 commit comments