@@ -127,7 +127,7 @@ let tests pkgUnderTestVersion =
127127 |> fun s -> s.Trim()
128128 |> asLines
129129
130- [
130+ let generalTests =
131131 testList " general" [
132132 testCase |> withLog " can show help" ( fun _ fs ->
133133
@@ -137,6 +137,7 @@ let tests pkgUnderTestVersion =
137137 )
138138 ]
139139
140+ let sanityChecks =
140141 testList " sanity check of projects" [
141142
142143 testCase |> withLog " can build sample1" ( fun _ fs ->
@@ -165,15 +166,51 @@ let tests pkgUnderTestVersion =
165166 let projPath = testDir/ ( `` samples2 NetSdk library `` .ProjectFile)
166167 let projDir = Path.GetDirectoryName projPath
167168
168- let result = dotnet fs [ " build" ; projPath]
169- result |> checkExitCodeZero
169+ dotnet fs [ " build" ; projPath]
170+ |> checkExitCodeZero
170171
171- let outputPath = projDir/ " bin" / " Debug" / " netstandard2.0" / `` samples2 NetSdk library `` .AssemblyName + " .dll"
172+ let tfm = `` samples2 NetSdk library `` .TargetFrameworks |> Map.toList |> List.map fst |> List.head
173+ let outputPath = projDir/ " bin" / " Debug" / tfm/ `` samples2 NetSdk library `` .AssemblyName + " .dll"
172174 Expect.isTrue ( File.Exists outputPath) ( sprintf " output assembly '%s ' not found" outputPath)
173175 )
174176
177+ testCase |> withLog " can build sample3" ( fun _ fs ->
178+ let testDir = inDir fs " sanity_check_sample2"
179+ copyDirFromAssets fs `` sample3 Netsdk projs `` .ProjDir testDir
180+
181+ let projPath = testDir/ ( `` sample3 Netsdk projs `` .ProjectFile)
182+ let projDir = Path.GetDirectoryName projPath
183+
184+ dotnet fs [ " build" ; projPath]
185+ |> checkExitCodeZero
186+
187+ let outputPath = projDir/ " bin" / " Debug" / " netcoreapp2.1" / `` sample3 Netsdk projs `` .AssemblyName + " .dll"
188+ Expect.isTrue ( File.Exists outputPath) ( sprintf " output assembly '%s ' not found" outputPath)
189+
190+ let result = dotnet fs [ " run" ; " -p" ; projPath; " --no-build" ]
191+ result |> checkExitCodeZero
192+
193+ Expect.equal " Hello World from F#!" ( result.Result.StandardOutput.Trim()) " check console out"
194+ )
195+
196+ testCase |> withLog " can build sample4" ( fun _ fs ->
197+ let testDir = inDir fs " sanity_check_sample4"
198+ copyDirFromAssets fs `` samples4 NetSdk multi tfm `` .ProjDir testDir
199+
200+ let projPath = testDir/ ( `` samples4 NetSdk multi tfm `` .ProjectFile)
201+ let projDir = Path.GetDirectoryName projPath
202+
203+ dotnet fs [ " build" ; projPath]
204+ |> checkExitCodeZero
205+
206+ for ( tfm, _) in `` samples4 NetSdk multi tfm `` .TargetFrameworks |> Map.toList do
207+ let outputPath = projDir/ " bin" / " Debug" / tfm/ `` samples4 NetSdk multi tfm `` .AssemblyName + " .dll"
208+ Expect.isTrue ( File.Exists outputPath) ( sprintf " output assembly '%s ' not found" outputPath)
209+ )
210+
175211 ]
176212
213+ let netFwTests =
177214 testList " .net" [
178215 testCase |> withLog " can show installed .net frameworks" ( fun _ fs ->
179216
@@ -202,6 +239,7 @@ let tests pkgUnderTestVersion =
202239 )
203240 ]
204241
242+ let oldSdkTests =
205243 testList " old sdk" [
206244 testCase |> withLog " can read properties" ( fun _ fs ->
207245 let testDir = inDir fs " oldsdk_props"
@@ -225,8 +263,9 @@ let tests pkgUnderTestVersion =
225263 )
226264 ]
227265
266+ let netSdkTests =
228267 testList " .net sdk" [
229- testCase |> withLog " can read properties" ( fun _ fs ->
268+ yield testCase |> withLog " can read properties" ( fun _ fs ->
230269 let testDir = inDir fs " netsdk_props"
231270 copyDirFromAssets fs `` samples2 NetSdk library `` .ProjDir testDir
232271
@@ -237,10 +276,12 @@ let tests pkgUnderTestVersion =
237276
238277 let result = projInfo fs [ projPath; " --get-property" ; " TargetFramework" ]
239278 result |> checkExitCodeZero
240- Expect.equal " TargetFramework=netstandard2.0" ( result.Result.StandardOutput.Trim()) " wrong output"
279+ let tfm = `` samples2 NetSdk library `` .TargetFrameworks |> Map.toList |> List.map fst |> List.head
280+ let out = result.Result.StandardOutput.Trim()
281+ Expect.equal out ( sprintf " TargetFramework=%s " tfm) " wrong output"
241282 )
242283
243- testCase |> withLog " can read fsc args" ( fun _ fs ->
284+ yield testCase |> withLog " can read fsc args" ( fun _ fs ->
244285 let testDir = inDir fs " netsdk_fsc_args"
245286 copyDirFromAssets fs `` samples2 NetSdk library `` .ProjDir testDir
246287
@@ -252,7 +293,83 @@ let tests pkgUnderTestVersion =
252293 let result = projInfo fs [ projPath; " --fsc-args" ]
253294 result |> checkExitCodeZero
254295 )
296+
297+ for conf in [ " Debug" ; " Release" ] do
298+ yield testCase |> withLog ( sprintf " can read properties for conf (%s )" conf) ( fun _ fs ->
299+ let testDir = inDir fs ( sprintf " netsdk_props_%s " ( conf.ToLower()))
300+ copyDirFromAssets fs `` samples2 NetSdk library `` .ProjDir testDir
301+
302+ let projPath = testDir/ ( `` samples2 NetSdk library `` .ProjectFile)
303+
304+ dotnet fs [ " restore" ; projPath]
305+ |> checkExitCodeZero
306+
307+ let result = projInfo fs [ projPath; " -gp" ; " OutputPath" ; " -c" ; conf]
308+ result |> checkExitCodeZero
309+ let out = result.Result.StandardOutput.Trim()
310+
311+ let tfm = `` samples2 NetSdk library `` .TargetFrameworks |> Map.toList |> List.map fst |> List.head
312+ let expectedPath = " bin" / conf/ tfm + Path.DirectorySeparatorChar.ToString()
313+ Expect.equal out ( sprintf " OutputPath=%s " expectedPath) " wrong output"
314+ )
315+
316+ yield testCase |> withLog " can read project references" ( fun _ fs ->
317+ let testDir = inDir fs " netsdk_proj_refs"
318+ copyDirFromAssets fs `` sample3 Netsdk projs `` .ProjDir testDir
319+
320+ let projPath = testDir/ ( `` sample3 Netsdk projs `` .ProjectFile)
321+
322+ dotnet fs [ " restore" ; projPath]
323+ |> checkExitCodeZero
324+
325+ let result = projInfo fs [ projPath; " --project-refs" ]
326+ result |> checkExitCodeZero
327+
328+ let out = stdOutLines result
329+
330+ let p2ps =
331+ `` sample3 Netsdk projs `` .ProjectReferences
332+ |> List.map ( fun p2p -> testDir/ p2p.ProjectFile)
333+
334+ Expect.equal out p2ps " p2ps"
335+ )
336+
337+ for ( tfm, infoOfTfm) in `` samples4 NetSdk multi tfm `` .TargetFrameworks |> Map.toList do
338+ yield testCase |> withLog ( sprintf " can read fsc args of multitarget (%s )" tfm) ( fun _ fs ->
339+ let testDir = inDir fs ( sprintf " netsdk_fsc_args_multi_%s " tfm)
340+ copyDirFromAssets fs `` samples4 NetSdk multi tfm `` .ProjDir testDir
341+
342+ let projPath = testDir/ ( `` samples4 NetSdk multi tfm `` .ProjectFile)
343+
344+ dotnet fs [ " restore" ; projPath]
345+ |> checkExitCodeZero
346+
347+ let result = projInfo fs [ projPath; " --fsc-args" ; " -f" ; tfm]
348+ result |> checkExitCodeZero
349+ )
350+
351+ yield testCase |> withLog ( sprintf " can read properties of multitarget (%s )" tfm) ( fun _ fs ->
352+ let testDir = inDir fs ( sprintf " netsdk_props_multi_%s " tfm)
353+ copyDirFromAssets fs `` samples4 NetSdk multi tfm `` .ProjDir testDir
354+
355+ let projPath = testDir/ ( `` samples4 NetSdk multi tfm `` .ProjectFile)
356+
357+ dotnet fs [ " restore" ; projPath]
358+ |> checkExitCodeZero
359+
360+ let result = projInfo fs [ projPath; " -f" ; tfm; " --get-property" ; " MyProperty" ]
361+ result |> checkExitCodeZero
362+ let out = result.Result.StandardOutput.Trim()
363+ let prop = infoOfTfm.Props |> Map.find " MyProperty"
364+ Expect.equal out ( sprintf " MyProperty=%s " prop) " wrong output"
365+ )
366+
255367 ]
256368
257- ]
369+ [ generalTests
370+ sanityChecks
371+ netFwTests
372+ oldSdkTests
373+ netSdkTests ]
258374 |> testList " suite"
375+ |> testSequenced
0 commit comments