Skip to content

Commit

Permalink
Merge pull request #5 from microsoftgraph/feature/dotnet-core
Browse files Browse the repository at this point in the history
Feature/dotnet core
  • Loading branch information
baywet authored Dec 10, 2020
2 parents d070944 + bea5bd4 commit 9ef3c3a
Show file tree
Hide file tree
Showing 30 changed files with 245 additions and 1,055 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "OSS/markdowndeep"]
path = OSS/markdowndeep
url = https://github.com/OneDrive/markdowndeep.git
branch = master
6 changes: 0 additions & 6 deletions .nuget/NuGet.Config

This file was deleted.

Binary file removed .nuget/NuGet.exe
Binary file not shown.
144 changes: 0 additions & 144 deletions .nuget/NuGet.targets

This file was deleted.

116 changes: 14 additions & 102 deletions ApiDoctor.Console/ApiDoctor.ConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A6F3993F-59C6-4985-ACF1-4D837D61E98F}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>true</IsPackable>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ApiDoctor.ConsoleApp</RootNamespace>
<AssemblyName>apidoc</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand All @@ -28,98 +21,27 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NuspecProperties>$(NuspecProperties);version=$(PackageVersion)</NuspecProperties>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Commandlineparameters>check-docs --path /Users/dspektor/src/graphdocs2</Commandlineparameters>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup>
<StartupObject>ApiDoctor.ConsoleApp.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.23.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.23.302261847\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.23.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.23.302261847\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppVeyor\BuildWorkerApi.cs" />
<Compile Include="Auth\BasicAccount.cs" />
<Compile Include="Auth\OAuthAccount.cs" />
<Compile Include="Auth\OAuthAccountException.cs" />
<Compile Include="Auth\OAuthTokenGenerator.cs" />
<Compile Include="CheckResults.cs" />
<Compile Include="CommandLineOptions.cs" />
<Compile Include="FancyConsole.cs" />
<Compile Include="GitHelper.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestReport.cs" />
<Compile Include="AppConfigFile.cs" />
<Compile Include="WildcardExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="35MSSharedLib1024.snk" />
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApiDoctor.DocumentationGeneration\ApiDoctor.DocumentationGeneration.csproj">
<Project>{cd27998c-4021-4299-970b-91be877fd01b}</Project>
<Name>ApiDoctor.DocumentationGeneration</Name>
</ProjectReference>
<ProjectReference Include="..\ApiDoctor.Publishing\ApiDoctor.Publishing.csproj">
<Project>{B675CF73-AA42-4A54-B5E7-FF5F155DA4A7}</Project>
<Name>ApiDoctor.Publishing</Name>
</ProjectReference>
<ProjectReference Include="..\ApiDoctor.Validation\ApiDoctor.Validation.csproj">
<Project>{33B10320-3802-49CF-8965-3510AE66D5EC}</Project>
<Name>ApiDoctor.Validation</Name>
</ProjectReference>
<ProjectReference Include="..\ApiDoctor.DocumentationGeneration\ApiDoctor.DocumentationGeneration.csproj" />
<ProjectReference Include="..\ApiDoctor.Publishing\ApiDoctor.Publishing.csproj" />
<ProjectReference Include="..\ApiDoctor.Validation\ApiDoctor.Validation.csproj" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
Expand All @@ -138,19 +60,9 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions ApiDoctor.Console/ApiDoctor.ConsoleApp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<licenseUrl>http://msdn.microsoft.com/en-US/cc300389</licenseUrl>
<projectUrl>http://github.com/onedrive/apidoctor</projectUrl>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" targetFramework="net45" />
</frameworkAssemblies>
</metadata>
<files>
<file src="bin\Release\apidoc.exe" target="tools" />
<file src="bin\Release\*.dll" target="tools" />
<file src="bin\Release\net5.0\apidoc.exe" target="tools" />
<file src="bin\Release\net5.0\*.dll" target="tools" />
<file src="bin\Release\net5.0\*.json" target="tools" />
<file src="bin\Release\net5.0\runtimes\**" target="tools\runtimes" />
<file src="bin\Release\net5.0\ref\**" target="tools\ref" />
</files>
</package>
6 changes: 0 additions & 6 deletions ApiDoctor.Console/App.config

This file was deleted.

24 changes: 18 additions & 6 deletions ApiDoctor.Console/Auth/OAuthAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace ApiDoctor.ConsoleApp.Auth
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;

public class OAuthAccount : IServiceAccount
{
Expand Down Expand Up @@ -202,13 +203,24 @@ private async Task RedeemRefreshTokenAsync()
private async Task RedeemUsernameAndPasswordAsync()
{
if (string.IsNullOrEmpty(this.AccessToken))
{
var creds = new Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential(this.Username, this.Password);
var context = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(this.TokenService);
var token = await context.AcquireTokenAsync(this.Resource, this.ClientId, creds);
if (null != token)
{ // MSAL removed username/password flow in an effort to discourage people from using it in their applications
// it's meant to be replaced by device code flow but because we're using the tool in an unattended mode, we can't implement device code.
// this implement a call to the endpoint directly https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc
using var client = new HttpClient();
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("username", this.Username),
new KeyValuePair<string, string>("password", this.Password),
new KeyValuePair<string, string>("scope", this.Scopes.Aggregate((x, y) => $"{x} {y}")),
new KeyValuePair<string, string>("client_id", this.ClientId),
new KeyValuePair<string, string>("grant_type", "password"),
});
using var response = await client.PostAsync(this.TokenService, content); // "https://login.microsoftonline.com/common/oauth2.0/token"
var stringBody = await response.Content.ReadAsStringAsync();
var jsonContent = JsonConvert.DeserializeObject<dynamic>(stringBody);
if (!string.IsNullOrEmpty(jsonContent.access_token))
{
this.AccessToken = token.AccessToken;
this.AccessToken = jsonContent.access_token;
}
else
{
Expand Down
Loading

0 comments on commit 9ef3c3a

Please sign in to comment.