@@ -28,6 +28,29 @@ string[] GetNuGetSources()
2828 return adds . ToArray ( ) ;
2929}
3030
31+ ProcessArgumentBuilder AppendForwardingLogger ( ProcessArgumentBuilder args )
32+ {
33+ if ( BuildSystem . IsLocalBuild )
34+ return args ;
35+
36+ // URL copied from https://github.com/microsoft/azure-pipelines-tasks/blob/7faf3e8146d43753b9f360edfae3d2e75ad78c76/Tasks/DotNetCoreCLIV2/make.json
37+ var loggerUrl = "https://vstsagenttools.blob.core.windows.net/tools/msbuildlogger/3/msbuildlogger.zip" ;
38+
39+ var AGENT_TEMPDIRECTORY = ( DirectoryPath ) EnvironmentVariable ( "AGENT_TEMPDIRECTORY" ) ;
40+ var loggerDir = AGENT_TEMPDIRECTORY . Combine ( "msbuildlogger" ) ;
41+ EnsureDirectoryExists ( loggerDir ) ;
42+
43+ var loggerZip = loggerDir . CombineWithFilePath ( "msbuildlogger.zip" ) ;
44+ if ( ! FileExists ( loggerZip ) )
45+ DownloadFile ( loggerUrl , loggerZip ) ;
46+
47+ var loggerDll = loggerDir . CombineWithFilePath ( "Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" ) ;
48+ if ( ! FileExists ( loggerDll ) )
49+ Unzip ( loggerZip , loggerDir ) ;
50+
51+ return args . Append ( $ "-dl:CentralLogger,\" { loggerDll } \" *ForwardingLogger,\" { loggerDll } \" ") ;
52+ }
53+
3154void RunNuGetRestorePackagesConfig ( FilePath sln )
3255{
3356 var dir = sln . GetDirectory ( ) ;
@@ -160,6 +183,51 @@ void RunDotNetBuild(
160183 }
161184 }
162185 c . Sources = GetNuGetSources ( ) ;
186+
187+ c . ArgumentCustomization = AppendForwardingLogger ;
163188
164189 DotNetBuild ( solution . FullPath , c ) ;
165190}
191+
192+ void RunDotNetPack (
193+ FilePath solution ,
194+ DirectoryPath outputPath = null ,
195+ string bl = ".pack" ,
196+ string configuration = null ,
197+ string additionalArgs = null ,
198+ Dictionary < string , string > properties = null )
199+ {
200+ EnsureDirectoryExists ( OUTPUT_NUGETS_PATH ) ;
201+
202+ var c = new DotNetPackSettings ( ) ;
203+ var msb = new DotNetMSBuildSettings ( ) ;
204+ c . MSBuildSettings = msb ;
205+
206+ c . Configuration = configuration ?? CONFIGURATION ;
207+ c . Verbosity = DotNetVerbosity . Minimal ;
208+
209+ var relativeSolution = MakeAbsolute ( ROOT_PATH ) . GetRelativePath ( MakeAbsolute ( solution ) ) ;
210+ var blPath = ROOT_PATH . Combine ( "output/logs/binlogs" ) . CombineWithFilePath ( relativeSolution + bl + ".binlog" ) ;
211+ msb . BinaryLogger = new MSBuildBinaryLoggerSettings {
212+ Enabled = true ,
213+ FileName = blPath . FullPath ,
214+ } ;
215+
216+ c . NoBuild = true ;
217+
218+ c . OutputDirectory = outputPath ?? OUTPUT_NUGETS_PATH ;
219+
220+ msb . Properties [ "NoDefaultExcludes" ] = new [ ] { "true" } ;
221+
222+ if ( properties != null ) {
223+ foreach ( var prop in properties ) {
224+ if ( ! string . IsNullOrEmpty ( prop . Value ) ) {
225+ msb . Properties [ prop . Key ] = new [ ] { prop . Value } ;
226+ }
227+ }
228+ }
229+
230+ c . ArgumentCustomization = args => AppendForwardingLogger ( args ) . Append ( additionalArgs ) ;
231+
232+ DotNetPack ( solution . FullPath , c ) ;
233+ }
0 commit comments