diff --git a/ClientLibrary/Samples/.vscode/launch.json b/ClientLibrary/Samples/.vscode/launch.json
new file mode 100644
index 00000000..85de6b9f
--- /dev/null
+++ b/ClientLibrary/Samples/.vscode/launch.json
@@ -0,0 +1,27 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (console)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/ClientSamples.netcore.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
+ "console": "internalConsole",
+ "stopAtEntry": false
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ClientLibrary/Samples/.vscode/tasks.json b/ClientLibrary/Samples/.vscode/tasks.json
new file mode 100644
index 00000000..3f1ebab5
--- /dev/null
+++ b/ClientLibrary/Samples/.vscode/tasks.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/ClientSamples.netcore.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/ClientSamples.netcore.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "${workspaceFolder}/ClientSamples.netcore.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ClientLibrary/Samples/ClientSample.cs b/ClientLibrary/Samples/ClientSample.cs
index c66438be..3bda3a70 100644
--- a/ClientLibrary/Samples/ClientSample.cs
+++ b/ClientLibrary/Samples/ClientSample.cs
@@ -66,7 +66,17 @@ public ClientSampleContext(Uri url, VssCredentials credentials)
if (credentials == null)
{
+#if NETCOREAPP
+ string pat = Environment.GetEnvironmentVariable(Program.PAT_ENV_VAR);
+ if (string.IsNullOrEmpty(pat))
+ {
+ throw new ArgumentException("On .NET Core, you must set an environment variable " + Program.PAT_ENV_VAR + " with a personal access token.");
+ }
+
+ this.Credentials = new VssBasicCredential("pat", pat);
+#else
this.Credentials = new VssClientCredentials();
+#endif
}
else
{
diff --git a/ClientLibrary/Samples/ClientSamples.netcore.csproj b/ClientLibrary/Samples/ClientSamples.netcore.csproj
new file mode 100644
index 00000000..65ee519f
--- /dev/null
+++ b/ClientLibrary/Samples/ClientSamples.netcore.csproj
@@ -0,0 +1,23 @@
+
+
+
+ Exe
+ netcoreapp3.1
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ClientLibrary/Samples/ClientSamples.netcore.sln b/ClientLibrary/Samples/ClientSamples.netcore.sln
new file mode 100644
index 00000000..6cf4fc9b
--- /dev/null
+++ b/ClientLibrary/Samples/ClientSamples.netcore.sln
@@ -0,0 +1,34 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26124.0
+MinimumVisualStudioVersion = 15.0.26124.0
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSamples.netcore", "ClientSamples.netcore.csproj", "{C9F7FF01-ACDB-4866-B185-AC06D45E09EC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|x64.Build.0 = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Debug|x86.Build.0 = Debug|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|x64.ActiveCfg = Release|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|x64.Build.0 = Release|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|x86.ActiveCfg = Release|Any CPU
+ {C9F7FF01-ACDB-4866-B185-AC06D45E09EC}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/ClientLibrary/Samples/ClientSamplesProgram.cs b/ClientLibrary/Samples/ClientSamplesProgram.cs
index 95093de9..79cc468e 100644
--- a/ClientLibrary/Samples/ClientSamplesProgram.cs
+++ b/ClientLibrary/Samples/ClientSamplesProgram.cs
@@ -15,6 +15,8 @@ namespace Microsoft.Azure.DevOps.ClientSamples
///
public class Program
{
+ public const string PAT_ENV_VAR = "AZURE_DEVOPS_PAT";
+
public static int Main(string[] args)
{
if (args.Length == 0)
@@ -40,6 +42,16 @@ public static int Main(string[] args)
return -1;
}
+#if NETCOREAPP
+ string checkPat = Environment.GetEnvironmentVariable(PAT_ENV_VAR);
+ if (string.IsNullOrEmpty(checkPat))
+ {
+ Console.WriteLine("On .NET Core, you must set an environment variable " + PAT_ENV_VAR + " with a personal access token.");
+ return -1;
+ }
+#endif
+
+
try
{
ClientSampleUtils.RunClientSampleMethods(connectionUrl, null, area: area, resource: resource, outputPath: outputPath);
@@ -93,7 +105,7 @@ private static void CheckArguments(string[] args, out Uri connectionUrl, out str
if (connectionUrl == null || area == null || resource == null)
{
throw new ArgumentException("Missing required arguments");
- }
+ }
}
private static void ShowUsage() {
diff --git a/ClientLibrary/Samples/Properties/AssemblyInfo.cs b/ClientLibrary/Samples/Properties/AssemblyInfo.cs
index 690e51a7..6e6e7499 100644
--- a/ClientLibrary/Samples/Properties/AssemblyInfo.cs
+++ b/ClientLibrary/Samples/Properties/AssemblyInfo.cs
@@ -4,12 +4,12 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("Microsoft Visual Studio Team Services Client Library Samples")]
+[assembly: AssemblyTitle("Microsoft Azure DevOps Client Library Samples")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("Visual Studio Team Services")]
-[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyProduct("Azure DevOps")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/ClientLibrary/Samples/README.md b/ClientLibrary/Samples/README.md
index 5a4046a1..0cf7e121 100644
--- a/ClientLibrary/Samples/README.md
+++ b/ClientLibrary/Samples/README.md
@@ -10,6 +10,19 @@ Samples are organized by "area" (service) and "resource". Each sample class show
## Run the samples
+1. Clone this repository.
+
+2. Build the solution using .NET Core 3.1 or later.
+
+3. Run `dotnet run --project ClientSamples.netcore.csproj` with the required arguments:
+ * `/url:{value}`: URL of the account/collection to run the samples against.
+ * `/area:{value}`: API area (work, wit, notification, git, core, build) to run the client samples for. Use * to include all areas. Be sure to escape the * if you're on a Unix.
+ * `/resource:{value}`: API resource to run the client samples for. Use * to include all resources. Be sure to escape the * if you're on a Unix.
+
+> **IMPORTANT**: some samples are destructive. It is recommended that you run these samples against a test account.
+
+## Run the samples - .NET Framework
+
1. Clone this repository and open in Visual Studio (2015 or later)
2. Build the solution (you may need to restore the required NuGet packages first)
diff --git a/ClientLibrary/Samples/Release/ReleasesSample.cs b/ClientLibrary/Samples/Release/ReleasesSample.cs
index c754b935..25b693ff 100644
--- a/ClientLibrary/Samples/Release/ReleasesSample.cs
+++ b/ClientLibrary/Samples/Release/ReleasesSample.cs
@@ -602,6 +602,9 @@ public IEnumerable ListDeploymentsForAGivenDefinitionId()
return deployments;
}
+#if NETCOREAPP
+// not working in netcore3.1
+#else
[ClientSampleMethod]
public IEnumerable ListAllDeploymentsForASpecificReleaseDefinitionId()
{
@@ -642,6 +645,7 @@ public IEnumerable ListAllDeploymentsForASpecificReleaseDefinitionId
return deployments;
}
+#endif
[ClientSampleMethod]
public System.IO.Stream GetLogsOfReleaseTask()
diff --git a/ClientLibrary/Samples/Serviceendpoint/EndpointsSample.cs b/ClientLibrary/Samples/Serviceendpoint/EndpointsSample.cs
index a211a5c3..87785b23 100644
--- a/ClientLibrary/Samples/Serviceendpoint/EndpointsSample.cs
+++ b/ClientLibrary/Samples/Serviceendpoint/EndpointsSample.cs
@@ -1,4 +1,7 @@
-using System;
+#if NETCOREAPP
+// not working in netcore3.1
+#else
+using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.FormInput;
@@ -178,4 +181,4 @@ public void DeleteServiceEndpoint()
}
}
}
-
+#endif