2
2
using HostApi ;
3
3
using Microsoft . Extensions . DependencyInjection ;
4
4
using NuGet . Versioning ;
5
+ // ReSharper disable SeparateLocalFunctionsWithJumpStatement
6
+ // ReSharper disable UnusedVariable
5
7
6
8
// Output, logging and tracing API
7
9
WriteLine ( "Hello" ) ;
58
60
}
59
61
60
62
// API for .NET CLI
61
- var buildResult = new DotNetBuild ( ) . WithConfiguration ( configuration ) . WithNoLogo ( true )
63
+ var buildResult = new DotNetBuild ( )
64
+ . WithConfiguration ( configuration )
65
+ . WithNoLogo ( true )
62
66
. Build ( ) . EnsureSuccess ( ) ;
63
67
64
68
var warnings = buildResult . Warnings
76
80
77
81
// Asynchronous way
78
82
var cts = new CancellationTokenSource ( ) ;
79
- /* await new DotNetTest()
83
+ await new DotNetTest ( )
80
84
. WithConfiguration ( configuration )
81
- .WithNoLogo(true).WithNoBuild(true)
82
- .BuildAsync(CancellationOnFirstFailedTest, cts.Token )
83
- .EnsureSuccess();*/
85
+ . WithNoLogo ( true )
86
+ . WithNoBuild ( true )
87
+ . BuildAsync ( CancellationOnFirstFailedTest , cts . Token ) ;
84
88
85
89
void CancellationOnFirstFailedTest ( BuildMessage message )
86
90
{
@@ -95,20 +99,35 @@ void CancellationOnFirstFailedTest(BuildMessage message)
95
99
96
100
async Task < IEnumerable < IBuildResult > > RunTestsAsync ( string framework , params string [ ] platforms )
97
101
{
98
- var publish = new DotNetPublish ( ) . WithWorkingDirectory ( "MySampleLib.Tests" )
99
- . WithFramework ( $ "net{ framework } ") . WithConfiguration ( configuration ) . WithNoBuild ( true ) ;
102
+ var publish = new DotNetPublish ( )
103
+ . WithWorkingDirectory ( "MySampleLib.Tests" )
104
+ . WithFramework ( $ "net{ framework } ")
105
+ . WithConfiguration ( configuration )
106
+ . WithNoBuild ( true ) ;
107
+
100
108
await publish . BuildAsync ( cancellationToken : cts . Token ) . EnsureSuccess ( ) ;
101
109
var publishPath = Path . Combine ( publish . WorkingDirectory , "bin" , configuration , $ "net{ framework } ", "publish" ) ;
102
110
103
- var test = new VSTest ( ) . WithTestFileNames ( "*.Tests.dll" ) ;
104
- var testInDocker = new DockerRun ( ) . WithCommandLine ( test ) . WithAutoRemove ( true ) . WithQuiet ( true )
105
- . WithVolumes ( ( Path . GetFullPath ( publishPath ) , "/app" ) ) . WithContainerWorkingDirectory ( "/app" ) ;
111
+ var test = new VSTest ( )
112
+ . WithTestFileNames ( "*.Tests.dll" ) ;
113
+
114
+ var testInDocker = new DockerRun ( )
115
+ . WithCommandLine ( test )
116
+ . WithAutoRemove ( true )
117
+ . WithQuiet ( true )
118
+ . WithVolumes ( ( Path . GetFullPath ( publishPath ) , "/app" ) )
119
+ . WithContainerWorkingDirectory ( "/app" ) ;
120
+
106
121
var tasks = from platform in platforms
107
122
let image = $ "mcr.microsoft.com/dotnet/sdk:{ framework } -{ platform } "
108
- select testInDocker . WithImage ( image ) . BuildAsync ( CancellationOnFirstFailedTest , cts . Token ) ;
123
+ select testInDocker
124
+ . WithImage ( image )
125
+ . BuildAsync ( CancellationOnFirstFailedTest , cts . Token ) ;
109
126
return await Task . WhenAll ( tasks ) ;
110
127
}
111
128
112
129
#pragma warning disable CS9113 // Parameter is unread.
113
- class MyTool ( INuGet nuGet ) ;
130
+
131
+ internal class MyTool ( INuGet nuGet ) ;
132
+
114
133
#pragma warning restore CS9113// Parameter is unread.
0 commit comments