Skip to content

Commit a727b93

Browse files
committed
Trying to support netcoreapp - limited by Microsoft.IdentityModel.Clients.ActiveDirectory support
1 parent dff1614 commit a727b93

File tree

9 files changed

+52
-216
lines changed

9 files changed

+52
-216
lines changed

ClientLibraryConsoleAppSample/ClientLibraryConsoleAppSample.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<TargetFramework>net452</TargetFramework>
5+
<!--<TargetFramework>netcoreapp2.0</TargetFramework>-->
56
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
67
<RootNamespace>ClientLibraryConsoleAppSample</RootNamespace>
78
<AssemblyName>ClientLibraryConsoleAppSample</AssemblyName>
89
</PropertyGroup>
910
<ItemGroup>
10-
<PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="15.118.0-preview" />
11+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.4" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
12+
<PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="16.139.0-preview" />
13+
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
14+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.1" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
15+
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
1116
</ItemGroup>
1217
<ItemGroup>
1318
<Reference Include="System" />
1419
<Reference Include="System.Net" />
15-
<Reference Include="System.Net.Http" />
20+
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == 'net452'" />
1621
<Reference Include="System.Runtime.Serialization" />
17-
<Reference Include="System.ServiceModel" />
22+
<Reference Include="System.ServiceModel" Condition="'$(TargetFramework)' == 'net452'" />
1823
<Reference Include="System.Xml" />
1924
</ItemGroup>
2025
</Project>

ClientLibraryConsoleAppSample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ClientLibraryConsoleAppSample
1111
class Program
1212
{
1313
//============= Config [Edit these with your settings] =====================
14-
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
14+
internal const string vstsCollectionUrl = "https://guidedultrasonics.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1515
// internal const string vstsCollectioUrl = "http://myserver:8080/tfs/DefaultCollection" alternate URL for a TFS collection
1616
//==========================================================================
1717

DeviceProfileSample/DeviceProfileSample.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net452</TargetFramework>
4+
<!--<TargetFramework>net452</TargetFramework>-->
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
56
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
67
<RootNamespace>DeviceProfileSample</RootNamespace>
78
<AssemblyName>DeviceProfileSample</AssemblyName>

DeviceProfileSample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace DeviceProfileSample
99
public class Program
1010
{
1111
//============= Config [Edit these with your settings] =====================
12-
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
12+
internal const string vstsCollectionUrl = "https://guidedultrasonics.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1313
internal const string clientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1"; //update this with your Application ID from step 2.6 (do not change this if you have an MSA backed account)
1414
//==========================================================================
1515

ManagedClientConsoleAppSample/App.config

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup>
3+
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
55
</startup>
66
<system.serviceModel>
@@ -33,20 +33,4 @@
3333
<!-- Service Bus specific app setings for messaging connections -->
3434
<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://[your namespace].servicebus.windows.net;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[your secret]" />
3535
</appSettings>
36-
<runtime>
37-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
38-
<dependentAssembly>
39-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
40-
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
41-
</dependentAssembly>
42-
<dependentAssembly>
43-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
44-
<bindingRedirect oldVersion="0.0.0.0-3.13.8.999" newVersion="3.13.8.999" />
45-
</dependentAssembly>
46-
<dependentAssembly>
47-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" />
48-
<bindingRedirect oldVersion="0.0.0.0-3.13.8.999" newVersion="3.13.8.999" />
49-
</dependentAssembly>
50-
</assemblyBinding>
51-
</runtime>
5236
</configuration>

ManagedClientConsoleAppSample/ManagedClientConsoleAppSample.csproj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net452</TargetFramework>
4+
<TargetFrameworks>net452</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
56
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
67
<RootNamespace>ManagedClientConsoleAppSample</RootNamespace>
78
<AssemblyName>ManagedClientConsoleAppSample</AssemblyName>
89
</PropertyGroup>
910
<ItemGroup>
10-
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.13.8" />
11-
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="15.112.1" />
12-
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
11+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.4" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
12+
<!--<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" />-->
13+
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="15.134.0-preview" />
14+
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
15+
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
1316
</ItemGroup>
1417
<ItemGroup>
1518
<Reference Include="Microsoft.CSharp" />
1619
<Reference Include="System" />
1720
<Reference Include="System.Core" />
1821
<Reference Include="System.Data" />
19-
<Reference Include="System.Data.DataSetExtensions" />
20-
<Reference Include="System.Net.Http" />
22+
<Reference Include="System.Data.DataSetExtensions" Condition="'$(TargetFramework)' == 'net452'"/>
23+
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == 'net452'" />
2124
<Reference Include="System.Runtime.Serialization" />
22-
<Reference Include="System.ServiceModel" />
25+
<Reference Include="System.ServiceModel" Condition="'$(TargetFramework)' == 'net452'" />
2326
<Reference Include="System.Xml" />
2427
<Reference Include="System.Xml.Linq" />
2528
</ItemGroup>

ManagedClientConsoleAppSample/Program.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ManagedClientConsoleAppSample
1111
class Program
1212
{
1313
//============= Config [Edit these with your settings] =====================
14-
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
14+
internal const string vstsCollectionUrl = "https://guidedultrasonics.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1515
internal const string clientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1"; //change to your app registration's Application ID, unless you are an MSA backed account
1616
internal const string replyUri = "urn:ietf:wg:oauth:2.0:oob"; //change to your app registration's reply URI, unless you are an MSA backed account
1717
//==========================================================================
@@ -22,10 +22,17 @@ public static void Main(string[] args)
2222
{
2323
AuthenticationContext ctx = GetAuthenticationContext(null);
2424
AuthenticationResult result = null;
25+
26+
#if NET452
27+
IPlatformParameters p = new PlatformParameters(PromptBehavior.Always);
28+
#else
29+
IPlatformParameters p = new PlatformParameters();
30+
#endif
2531
try
2632
{
33+
2734
//PromptBehavior.RefreshSession will enforce an authn prompt every time. NOTE: Auto will take your windows login state if possible
28-
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri(replyUri), new PlatformParameters(PromptBehavior.Always)).Result;
35+
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri(replyUri), p).Result;
2936
Console.WriteLine("Token expires on: " + result.ExpiresOn);
3037

3138
var bearerAuthHeader = new AuthenticationHeaderValue("Bearer", result.AccessToken);
@@ -34,7 +41,7 @@ public static void Main(string[] args)
3441
catch (UnauthorizedAccessException)
3542
{
3643
// If the token has expired, prompt the user with a login prompt
37-
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri(replyUri), new PlatformParameters(PromptBehavior.Always)).Result;
44+
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri(replyUri), p).Result;
3845
}
3946
catch (Exception ex)
4047
{
@@ -67,7 +74,7 @@ private static void ListProjects(AuthenticationHeaderValue authHeader)
6774
{
6875
client.BaseAddress = new Uri(vstsCollectionUrl);
6976
client.DefaultRequestHeaders.Accept.Clear();
70-
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
77+
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
7178
client.DefaultRequestHeaders.Add("User-Agent", "ManagedClientConsoleAppSample");
7279
client.DefaultRequestHeaders.Add("X-TFS-FedAuthRedirect", "Suppress");
7380
client.DefaultRequestHeaders.Authorization = authHeader;
@@ -79,7 +86,8 @@ private static void ListProjects(AuthenticationHeaderValue authHeader)
7986
if (response.IsSuccessStatusCode)
8087
{
8188
Console.WriteLine("\tSuccesful REST call");
82-
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
89+
var result = response.Content.ReadAsStringAsync().Result;
90+
Console.WriteLine(result);
8391
}
8492
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
8593
{
Lines changed: 16 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,27 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{2A8F9A96-2FB4-4FCA-A67C-44C757D354E3}</ProjectGuid>
83
<OutputType>Exe</OutputType>
4+
<TargetFramework>net461</TargetFramework>
5+
<!--<TargetFramework>netcoreapp2.0</TargetFramework>-->
6+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
97
<RootNamespace>NonInteractivePatGenerationSample</RootNamespace>
108
<AssemblyName>NonInteractivePatGenerationSample</AssemblyName>
11-
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12-
<FileAlignment>512</FileAlignment>
13-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14-
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<PlatformTarget>AnyCPU</PlatformTarget>
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<PlatformTarget>AnyCPU</PlatformTarget>
27-
<DebugType>pdbonly</DebugType>
28-
<Optimize>true</Optimize>
29-
<OutputPath>bin\Release\</OutputPath>
30-
<DefineConstants>TRACE</DefineConstants>
31-
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
339
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
12+
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.17.0" />
13+
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="15.112.1" />
14+
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'netcoreapp2.0'" />
15+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.1" />
16+
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
17+
</ItemGroup>
3418
<ItemGroup>
3519
<Reference Include="System" />
36-
<Reference Include="System.ComponentModel.Composition" />
37-
<Reference Include="System.Core" />
38-
<Reference Include="System.Net.Http" />
39-
<Reference Include="System.Runtime.Serialization" />
40-
<Reference Include="System.ServiceModel" />
41-
<Reference Include="System.Xml.Linq" />
42-
<Reference Include="System.Data.DataSetExtensions" />
43-
<Reference Include="Microsoft.CSharp" />
4420
<Reference Include="System.Data" />
21+
<Reference Include="System.Net" />
22+
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == 'net452'" />
23+
<Reference Include="System.Runtime.Serialization" />
24+
<Reference Include="System.ServiceModel" Condition="'$(TargetFramework)' == 'net452'" />
4525
<Reference Include="System.Xml" />
4626
</ItemGroup>
47-
<ItemGroup>
48-
<Compile Include="Program.cs" />
49-
<Compile Include="Properties\AssemblyInfo.cs" />
50-
</ItemGroup>
51-
<ItemGroup>
52-
<None Include="App.config" />
53-
</ItemGroup>
54-
<ItemGroup>
55-
<PackageReference Include="Microsoft.AspNet.WebApi.Client">
56-
<Version>5.2.3</Version>
57-
</PackageReference>
58-
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
59-
<Version>3.17.0</Version>
60-
</PackageReference>
61-
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient">
62-
<Version>15.112.1</Version>
63-
</PackageReference>
64-
<!--
65-
<PackageReference Include="Microsoft.Win32.Primitives">
66-
<Version>4.3.0</Version>
67-
</PackageReference>
68-
-->
69-
<PackageReference Include="Newtonsoft.Json">
70-
<Version>10.0.3</Version>
71-
</PackageReference>
72-
<!--
73-
<PackageReference Include="System.Collections">
74-
<Version>4.3.0</Version>
75-
</PackageReference>
76-
<PackageReference Include="System.Collections.Concurrent">
77-
<Version>4.3.0</Version>
78-
</PackageReference>
79-
<PackageReference Include="System.Diagnostics.Debug">
80-
<Version>4.3.0</Version>
81-
</PackageReference>
82-
<PackageReference Include="System.Diagnostics.DiagnosticSource">
83-
<Version>4.4.1</Version>
84-
</PackageReference>
85-
<PackageReference Include="System.Globalization">
86-
<Version>4.3.0</Version>
87-
</PackageReference>
88-
-->
89-
<PackageReference Include="System.IdentityModel.Tokens.Jwt">
90-
<Version>5.1.4</Version>
91-
</PackageReference>
92-
<!--
93-
<PackageReference Include="System.IO">
94-
<Version>4.3.0</Version>
95-
</PackageReference>
96-
<PackageReference Include="System.Linq">
97-
<Version>4.3.0</Version>
98-
</PackageReference>
99-
<PackageReference Include="System.Net.Http">
100-
<Version>4.3.3</Version>
101-
</PackageReference>
102-
<PackageReference Include="System.Net.Primitives">
103-
<Version>4.3.0</Version>
104-
</PackageReference>
105-
<PackageReference Include="System.Reflection">
106-
<Version>4.3.0</Version>
107-
</PackageReference>
108-
<PackageReference Include="System.Reflection.Extensions">
109-
<Version>4.3.0</Version>
110-
</PackageReference>
111-
<PackageReference Include="System.Runtime">
112-
<Version>4.3.0</Version>
113-
</PackageReference>
114-
<PackageReference Include="System.Runtime.Extensions">
115-
<Version>4.3.0</Version>
116-
</PackageReference>
117-
<PackageReference Include="System.Runtime.InteropServices">
118-
<Version>4.3.0</Version>
119-
</PackageReference>
120-
<PackageReference Include="System.Runtime.Serialization.Json">
121-
<Version>4.3.0</Version>
122-
</PackageReference>
123-
<PackageReference Include="System.Runtime.Serialization.Primitives">
124-
<Version>4.3.0</Version>
125-
</PackageReference>
126-
<PackageReference Include="System.Security.Cryptography.X509Certificates">
127-
<Version>4.3.1</Version>
128-
</PackageReference>
129-
<PackageReference Include="System.Text.Encoding">
130-
<Version>4.3.0</Version>
131-
</PackageReference>
132-
<PackageReference Include="System.Text.Encoding.Extensions">
133-
<Version>4.3.0</Version>
134-
</PackageReference>
135-
<PackageReference Include="System.Text.RegularExpressions">
136-
<Version>4.3.0</Version>
137-
</PackageReference>
138-
<PackageReference Include="System.Threading">
139-
<Version>4.3.0</Version>
140-
</PackageReference>
141-
<PackageReference Include="System.Threading.Tasks">
142-
<Version>4.3.0</Version>
143-
</PackageReference>
144-
<PackageReference Include="System.Xml.ReaderWriter">
145-
<Version>4.3.0</Version>
146-
</PackageReference>
147-
<PackageReference Include="System.Xml.XDocument">
148-
<Version>4.3.0</Version>
149-
</PackageReference>
150-
-->
151-
<PackageReference Include="WindowsAzure.ServiceBus">
152-
<Version>4.1.3</Version>
153-
</PackageReference>
154-
</ItemGroup>
155-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
15627
</Project>

NonInteractivePatGenerationSample/NonInteractivePatGenerationSample/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)