Rename client code generation components

- #8523
- main project / package --> `Microsoft.Extensions.ApiDescription.Design`
- tasks assembly and namespace --> `Microsoft.Extensions.ApiDescription.Tasks`
- tool namespace --> `Microsoft.Extensions.ApiDescription.Tool`
- targets --> verbs e.g. `GenerateTypeScriptNSwag` and `GenerateDocumentDefault`
- `@(ServiceProjectReference)` metadata -> align with common MSBuild project properties
  - exception: `$(MSBuildProjectExtensionsPath)`; it's readonly and `%(ProjectExtensionsPath)` is unambiguous
    - use `%(ProjectExtensionsPath)`
  - also add `%(Targets)` metadata and remove unused `%(ProjectRuntimeIdentifier)`
- `@(<ServiceProjectReferenceMetadata)` metadata -> align with MSBuild project properties
  - exceptions: `$(MSBuildProjectDirectory)`, `$(MSBuildProjectExtensionsPath)` and `$(MSBuildProjectName)`
    - readonly properties and names already unambiguous
This commit is contained in:
Doug Bunting 2018-10-06 20:07:49 -07:00
parent d3442f3590
commit 5cd86977ed
No known key found for this signature in database
GPG Key ID: 888B4EB7822B32E9
40 changed files with 266 additions and 232 deletions

View File

@ -121,7 +121,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-getdocument", "src\d
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetDocumentInsider", "src\GetDocumentInsider\GetDocumentInsider.csproj", "{2F683CF8-B055-46AE-BF83-9D1307F8D45F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.ApiDescription.Client", "src\Microsoft.Extensions.ApiDescription.Client\Microsoft.Extensions.ApiDescription.Client.csproj", "{34E3C302-B767-40C8-B538-3EE2BD4000C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.ApiDescription.Design", "src\Microsoft.Extensions.ApiDescription.Design\Microsoft.Extensions.ApiDescription.Design.csproj", "{34E3C302-B767-40C8-B538-3EE2BD4000C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -182,7 +182,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-getdocument", "src\d
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetDocumentInsider", "src\GetDocumentInsider\GetDocumentInsider.csproj", "{2F683CF8-B055-46AE-BF83-9D1307F8D45F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.ApiDescription.Client", "src\Microsoft.Extensions.ApiDescription.Client\Microsoft.Extensions.ApiDescription.Client.csproj", "{34E3C302-B767-40C8-B538-3EE2BD4000C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.ApiDescription.Design", "src\Microsoft.Extensions.ApiDescription.Design\Microsoft.Extensions.ApiDescription.Design.csproj", "{34E3C302-B767-40C8-B538-3EE2BD4000C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -4,7 +4,7 @@
"DefaultCompositeRule"
],
"packages": {
"Microsoft.Extensions.ApiDescription.Client": {
"Microsoft.Extensions.ApiDescription.Design": {
"Exclusions": {
"BUILD_ITEMS_FRAMEWORK": {
"*": "Package includes tool with different target frameworks."

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal class AnsiConsole
{

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class AnsiConstants
{

View File

@ -6,7 +6,7 @@ using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal class AnsiTextWriter
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal class CommandException : Exception
{

View File

@ -3,7 +3,7 @@
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal abstract class CommandBase
{

View File

@ -10,7 +10,7 @@ using System.Runtime.Loader;
#endif
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal class GetDocumentCommand : ProjectCommandBase
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
[Serializable]
public class GetDocumentCommandContext

View File

@ -7,7 +7,7 @@ using System.Reflection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal class GetDocumentCommandWorker
{

View File

@ -3,7 +3,7 @@
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal class HelpCommandBase : CommandBase
{

View File

@ -3,7 +3,7 @@
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal abstract class ProjectCommandBase : HelpCommandBase
{

View File

@ -4,7 +4,7 @@
<Description>GetDocument Command-line Tool inside man</Description>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.Extensions.ApiDescription.Client</RootNamespace>
<RootNamespace>Microsoft.Extensions.ApiDescription.Tool</RootNamespace>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
</PropertyGroup>

View File

@ -3,7 +3,7 @@
using System.Reflection;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class ProductInfo
{

View File

@ -4,9 +4,9 @@
using System;
using System.Text;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.Extensions.ApiDescription.Client.Commands;
using Microsoft.Extensions.ApiDescription.Tool.Commands;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class Program
{

View File

@ -1,5 +1,5 @@
// <auto-generated />
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
using System.Globalization;
using System.Reflection;
@ -8,7 +8,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
internal static class Resources
{
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.Extensions.ApiDescription.Client.Resources", typeof(Resources).GetTypeInfo().Assembly);
= new ResourceManager("Microsoft.Extensions.ApiDescription.Tool.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary>
/// The assembly to use.

View File

@ -3,9 +3,9 @@
using System;
using System.Linq;
using static Microsoft.Extensions.ApiDescription.Client.AnsiConstants;
using static Microsoft.Extensions.ApiDescription.Tool.AnsiConstants;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class Reporter
{

View File

@ -14,7 +14,7 @@ using Microsoft.Build.Utilities;
using Task = System.Threading.Tasks.Task;
using Utilities = Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Downloads a file.

View File

@ -4,7 +4,7 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Restore <see cref="ITaskItem"/>s from given property value.

View File

@ -7,7 +7,7 @@ using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Adds or corrects ClassName, Namespace and OutputPath metadata in ServiceFileReference items. Also stores final

View File

@ -6,7 +6,7 @@ using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Adds or corrects DocumentPath and project-related metadata in ServiceProjectReference items. Also stores final

View File

@ -7,7 +7,7 @@ using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Adds or corrects DocumentPath metadata in ServiceUriReference items.

View File

@ -6,7 +6,7 @@ using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
/// <summary>
/// Utility methods to serialize and deserialize <see cref="ITaskItem"/> metadata.

View File

@ -6,13 +6,16 @@
<!-- Do not complain about lack of lib folder. -->
<NoPackageAnalysis>true</NoPackageAnalysis>
<AssemblyName>Microsoft.Extensions.ApiDescription.Tasks</AssemblyName>
<Description>MSBuild tasks and targets for code generation</Description>
<EnableApiCheck>false</EnableApiCheck>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSource>false</IncludeSource>
<IncludeSymbols>false</IncludeSymbols>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageTags>Build Tasks;MSBuild;Swagger;Open API;code generation; Web API client</PackageTags>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
</PropertyGroup>

View File

@ -20,8 +20,8 @@
<files>
<file src="build\*" target="build" />
<file src="buildMultiTargeting\*" target="buildMultiTargeting" />
<file src="bin\$configuration$\net461\Microsoft.Extensions.ApiDescription.Client.*" target="tasks\net461" />
<file src="bin\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Client.*" target="tasks\netstandard2.0" />
<file src="bin\$configuration$\net461\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\net461" />
<file src="bin\$configuration$\netstandard2.0\Microsoft.Extensions.ApiDescription.Tasks.*" target="tasks\netstandard2.0" />
<file src="..\dotnet-getdocument\bin\$configuration$\netcoreapp2.1\dotnet-getdocument.*" target="tools" />
<file src="..\GetDocumentInsider\bin\$configuration$\net461\GetDocument.Insider.*" target="tools\net461" />
<file src="..\GetDocumentInsider\bin\x86\$configuration$\net461\GetDocument.Insider.*" target="tools\net461-x86" />

View File

@ -1,5 +1,5 @@
// <auto-generated />
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tasks
{
using System.Globalization;
using System.Reflection;
@ -8,7 +8,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
internal static class Resources
{
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.Extensions.ApiDescription.Client.Resources", typeof(Resources).GetTypeInfo().Assembly);
= new ResourceManager("Microsoft.Extensions.ApiDescription.Tasks.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary>
/// Multiple items have OutputPath='{0}'. All ServiceFileReference, ServiceProjectReference and ServiceUriReference items must have unique OutputPath metadata.

View File

@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<PropertyGroup>
<_ApiDescriptionTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyTarget Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionTasksAssemblyTarget)/Microsoft.Extensions.ApiDescription.Client.dll</_ApiDescriptionTasksAssemblyPath>
<_ApiDescriptionTasksAssemblyTarget
Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard2.0</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyTarget
Condition="'$(MSBuildRuntimeType)' != 'Core'">net461</_ApiDescriptionTasksAssemblyTarget>
<_ApiDescriptionTasksAssemblyPath>$(MSBuildThisFileDirectory)/../tasks/$(_ApiDescriptionTasksAssemblyTarget)/Microsoft.Extensions.ApiDescription.Tasks.dll</_ApiDescriptionTasksAssemblyPath>
<_ApiDescriptionTasksAssemblyTarget />
</PropertyGroup>
<UsingTask TaskName="GetCurrentItems" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="GetFileReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="GetProjectReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="GetUriReferenceMetadata" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.Extensions.ApiDescription.Client.DownloadFile" AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.Extensions.ApiDescription.Tasks.DownloadFile"
AssemblyFile="$(_ApiDescriptionTasksAssemblyPath)" />
<!--
Settings users may update as they see fit. All $(...Directory) values are interpreted relative to the client
@ -32,7 +35,7 @@
<ServiceFileReferenceDirectory
Condition="'$(ServiceFileReferenceDirectory)' != ''">$([MSBuild]::EnsureTrailingSlash('$(ServiceFileReferenceDirectory)'))</ServiceFileReferenceDirectory>
<DefaultDocumentGeneratorDefaultOptions Condition="'$(DefaultDocumentGeneratorDefaultOptions)' == ''" />
<GenerateDefaultDocumentDefaultOptions Condition="'$(GenerateDefaultDocumentDefaultOptions)' == ''" />
</PropertyGroup>
<!--
@ -42,37 +45,46 @@
<ItemDefinitionGroup>
<ServiceProjectReference>
<!--
Name of the API description document generator. Builds will invoke a target named
"%(DocumentGenerator)DocumentGenerator" to do actual document retrieval / generation.
Name of the API description document generator. Builds will invoke a target named
"Generate%(DocumentGenerator)Document" to do actual document retrieval / generation.
-->
<DocumentGenerator>Default</DocumentGenerator>
<!-- Server project metadata which is likely applicable to all document generators. -->
<!--
Full path of the project's generated assembly. Corresponds to $(TargetPath). Because common code builds server
projects, file exists prior to document generator invocation.
Server project's chosen configuration. Corresponds to $(Configuration) which likely matches client project's
$(Configuration).
-->
<ProjectAssemblyPath />
<!-- Server project's chosen configuration. Likely matches client project's configuration. -->
<ProjectConfiguration />
<Configuration />
<!--
Server project's extensions path. Corresponds to $(MSBuildProjectExtensionsPath). User must set this if
server project's value is not 'obj/'.
-->
<ProjectExtensionsPath />
<!-- Runtime identifier to use when building the server project. -->
<ProjectRuntimeIdentifier />
<!-- Server project's target framework. Defaults to $(TargetFramewok) or first of $(TargetFrameworks). -->
<ProjectTargetFramework />
<!-- Server project's target framework. Defaults to $(TargetFramework) or first of $(TargetFrameworks). -->
<TargetFramework />
<!--
Full path of the server project's generated assembly. Corresponds to $(TargetPath). Because common code builds
server projects, file exists prior to document generator invocation.
-->
<TargetPath />
<!--
Semicolon-separated list of targets in the server project that should be built. Default is empty, indicating
the default targets of the server project. Does not honor $(ProjectReferenceBuildTargets) because that property
is too general for these references and it's normally empty too.
-->
<Targets />
<!-- Metadata specific to the Default document generator (though other document generators are free to use it). -->
<!--
Metadata specific to the Default document generator (though other document generators are free to use it).
-->
<!--
Options added to Default document generator tool's command line. Defaults to
$(DefaultDocumentGeneratorDefaultOptions) if that is set in the client project.
$(GenerateDefaultDocumentDefaultOptions) if that is set in the client project.
-->
<DefaultDocumentGeneratorOptions />
<GenerateDefaultDocumentOptions />
<!--
Name of the document to generate. Passed to the %(Method) when using Default document generator. Default is set
in server project, falling back to "v1".
@ -108,7 +120,8 @@
<ClassName />
<!--
Code generator to use. Required and must end with "CSharp" or "TypeScript" (the currently-supported target
languages). Builds will invoke a target named "%(CodeGenerator)CodeGenerator" to do actual code generation.
languages) unless %(OutputPath) is set. Builds will invoke a target named "Generate%(CodeGenerator)" to do
actual code generation.
-->
<CodeGenerator />
<!--

View File

@ -2,34 +2,34 @@
<Project>
<!-- Internal settings. Not intended for customization. -->
<PropertyGroup>
<ServiceProjectReferenceGeneratorDependsOn>
_ServiceProjectReferenceGenerator_GetTargetFramework;
_ServiceProjectReferenceGenerator_GetProjectTargetPath;
_ServiceProjectReferenceGenerator_GetMetadata;
_ServiceProjectReferenceGenerator_Build;
_ServiceProjectReferenceGenerator_Core;
_ServiceProjectReferenceGenerator_SetMetadata
</ServiceProjectReferenceGeneratorDependsOn>
<ServiceUriReferenceGeneratorDependsOn>
_ServiceUriReferenceGenerator_GetMetadata;
_ServiceUriReferenceGenerator_Core
</ServiceUriReferenceGeneratorDependsOn>
<ServiceFileReferenceGeneratorDependsOn>
ServiceProjectReferenceGenerator;
ServiceUriReferenceGenerator;
_ServiceFileReferenceGenerator_GetMetadata;
_ServiceFileReferenceGenerator_Core;
_ServiceFileReferenceGenerator_SetMetadata
</ServiceFileReferenceGeneratorDependsOn>
<GenerateServiceProjectReferenceDocumentsDependsOn>
_GetTargetFrameworkForServiceProjectReferences;
_GetTargetPathForServiceProjectReferences;
_GetMetadataForServiceProjectReferences;
_BuildServiceProjectReferences;
_GenerateServiceProjectReferenceDocuments;
_CreateFileItemsForServiceProjectReferences
</GenerateServiceProjectReferenceDocumentsDependsOn>
<GenerateServiceUriReferenceDocumentsDependsOn>
_GetMetadataForServiceUriReferences;
_GenerateServiceUriReferenceDocuments
</GenerateServiceUriReferenceDocumentsDependsOn>
<GenerateServiceFileReferenceCodesDependsOn>
GenerateServiceProjectReferenceDocuments;
GenerateServiceUriReferenceDocuments;
_GetMetadataForServiceFileReferences;
_GenerateServiceFileReferenceCodes;
_CreateCompileItemsForServiceFileReferences
</GenerateServiceFileReferenceCodesDependsOn>
</PropertyGroup>
<!-- ServiceProjectReference support -->
<!--
Metadata setup phase 1: Ensure items have TargetFramework metadata. Call GetTargetFrameworks in the target project.
Inputs and outputs cause MSBuild to run target unconditionally and to batch it (run once per project).
Metadata setup phase 1: Ensure items have TargetFramework metadata. Calls GetTargetFrameworks in the target
project. Inputs and outputs cause MSBuild to run target unconditionally and to batch it (run once per project).
-->
<Target Name="_ServiceProjectReferenceGenerator_GetTargetFramework"
<Target Name="_GetTargetFrameworkForServiceProjectReferences"
Inputs="%(ServiceProjectReference.FullPath)"
Outputs="&lt;not-a-file !&gt;">
<PropertyGroup>
@ -56,8 +56,7 @@
</PropertyGroup>
<ItemGroup>
<ServiceProjectReference Update="@(ServiceProjectReference)" Condition="'%(FullPath)' == '$(_FullPath)'">
<ProjectTargetFramework
Condition="'%(ProjectTargetFramework)' == ''">$(_TargetFramework)</ProjectTargetFramework>
<TargetFramework Condition="'%(TargetFramework)' == ''">$(_TargetFramework)</TargetFramework>
</ServiceProjectReference>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
@ -70,16 +69,16 @@
</Target>
<!--
Metadata setup phase 2: Ensure items have ProjectTargetPath metadata. Call GetTargetPath in the target project.
Metadata setup phase 2: Ensure items have TargetPath metadata. Calls GetTargetPath in the target project.
Inputs and outputs cause MSBuild to run target unconditionally and batch it (run once per TargetFramework x
project combination).
-->
<Target Name="_ServiceProjectReferenceGenerator_GetProjectTargetPath"
<Target Name="_GetTargetPathForServiceProjectReferences"
Inputs="%(ServiceProjectReference.TargetFramework)%(FullPath)')"
Outputs="&lt;not-a-file !&gt;">
<PropertyGroup>
<_FullPath>%(ServiceProjectReference.FullPath)</_FullPath>
<_TargetFramework>%(ServiceProjectReference.ProjectTargetFramework)</_TargetFramework>
<_TargetFramework>%(ServiceProjectReference.TargetFramework)</_TargetFramework>
</PropertyGroup>
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
@ -95,25 +94,25 @@
</MSBuild>
<PropertyGroup>
<_ProjectTargetPath>%(_Temporary.FullPath)</_ProjectTargetPath>
<_TargetPath>%(_Temporary.FullPath)</_TargetPath>
</PropertyGroup>
<ItemGroup>
<ServiceProjectReference Update="@(ServiceProjectReference)"
Condition="'%(FullPath)' == '$(_FullPath)' AND '%(ProjectTargetFramework)' == '$(_TargetFramework)'">
<ProjectTargetPath>$(_ProjectTargetPath)</ProjectTargetPath>
Condition="'%(FullPath)' == '$(_FullPath)' AND '%(TargetFramework)' == '$(_TargetFramework)'">
<TargetPath>$(_TargetPath)</TargetPath>
</ServiceProjectReference>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
<PropertyGroup>
<_FullPath />
<_ProjectTargetPath />
<_TargetPath />
<_TargetFramework />
</PropertyGroup>
</Target>
<!-- Metadata setup phase 3: Ensure items have DocumentPath metadata. -->
<Target Name="_ServiceProjectReferenceGenerator_GetMetadata" Condition="'@(ServiceProjectReference)' != ''">
<Target Name="_GetMetadataForServiceProjectReferences" Condition="'@(ServiceProjectReference)' != ''">
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
@ -132,38 +131,40 @@
</ItemGroup>
</Target>
<Target Name="_ServiceProjectReferenceGenerator_Build"
<Target Name="_BuildServiceProjectReferences"
Condition="'$(BuildProjectReferences)' == 'true'"
Inputs="@(ServiceProjectReference)"
Outputs="%(ProjectTargetPath)">
Outputs="%(TargetPath)">
<MSBuild Projects="@(ServiceProjectReference -> Distinct())"
BuildInParallel="$(BuildInParallel)"
RemoveProperties="TargetFramework;TargetFrameworks;RuntimeIdentifier"
Targets="Restore;Build" />
Targets="%(Targets)" />
</Target>
<Target Name="_ServiceProjectReferenceGenerator_GetItems">
<Target Name="_GetCurrentServiceProjectReference">
<GetCurrentItems Input="$(GeneratorMetadata)">
<Output TaskParameter="Outputs" ItemName="CurrentServiceProjectReference" />
</GetCurrentItems>
</Target>
<Target Name="_ServiceProjectReferenceGenerator_Inner"
DependsOnTargets="_ServiceProjectReferenceGenerator_GetItems;$(GeneratorTarget)" />
<Target Name="_GenerateServiceProjectReferenceDocument"
DependsOnTargets="_GetCurrentServiceProjectReference;$(GeneratorTarget)" />
<Target Name="_ServiceProjectReferenceGenerator_Core" Inputs="@(ServiceProjectReference)" Outputs="%(DocumentPath)">
<Target Name="_GenerateServiceProjectReferenceDocuments"
Inputs="@(ServiceProjectReference)"
Outputs="%(DocumentPath)">
<MSBuild BuildInParallel="$(BuildInParallel)"
Projects="$(MSBuildProjectFullPath)"
Properties="GeneratorTargetPath=%(ServiceProjectReference.DocumentPath);GeneratorTarget=%(DocumentGenerator)DocumentGenerator;GeneratorMetadata=%(SerializedMetadata)"
Properties="GeneratorTargetPath=%(ServiceProjectReference.DocumentPath);GeneratorTarget=Generate%(DocumentGenerator)Document;GeneratorMetadata=%(SerializedMetadata)"
RemoveProperties="TargetFrameworks"
Targets="_ServiceProjectReferenceGenerator_Inner" />
Targets="_GenerateServiceProjectReferenceDocument" />
</Target>
<Target Name="_ServiceProjectReferenceGenerator_SetMetadata" Condition="'@(ServiceProjectReference)' != ''">
<!-- _ServiceProjectReferenceGenerator_GetMetadata guarantees %(DocumentPath) values are unique. -->
<Target Name="_CreateFileItemsForServiceProjectReferences" Condition="'@(ServiceProjectReference)' != ''">
<!-- GetProjectReferenceMetadata task guarantees %(DocumentPath) values are unique. -->
<ItemGroup>
<ServiceFileReference Remove="@(ServiceProjectReference -> '%(DocumentPath)')" />
<!-- Condition here is temporary. Useful while DefaultDocumentGenerator fails. -->
<!-- Condition here is temporary. Useful while GenerateDefaultDocument fails. -->
<ServiceFileReference Include="@(ServiceProjectReference -> '%(DocumentPath)')"
Condition="Exists('%(ServiceProjectReference.DocumentPath)')">
<SourceProject>%(ServiceProjectReference.FullPath)</SourceProject>
@ -171,22 +172,22 @@
</ItemGroup>
</Target>
<Target Name="ServiceProjectReferenceGenerator" DependsOnTargets="$(ServiceProjectReferenceGeneratorDependsOn)" />
<Target Name="GenerateServiceProjectReferenceDocuments"
DependsOnTargets="$(GenerateServiceProjectReferenceDocumentsDependsOn)" />
<!-- DefaultDocumentGenerator -->
<!-- GenerateDefaultDocument -->
<Target Name="DefaultDocumentGenerator">
<Target Name="GenerateDefaultDocument">
<ItemGroup>
<!-- @(CurrentServiceProjectReference) item group will never contain more than one item. -->
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
<Command>dotnet $(MSBuildThisFileDirectory)/../tools/dotnet-getdocument.dll --project %(FullPath) --output %(DocumentPath)</Command>
<DefaultDocumentGeneratorOptions
Condition="'%(DefaultDocumentGeneratorOptions)' == ''">$(DefaultDocumentGeneratorDefaultOptions)</DefaultDocumentGeneratorOptions>
<ProjectConfiguration
Condition="'%(ProjectConfiguration)' == ''">$(Configuration)</ProjectConfiguration>
<Command>dotnet $(MSBuildThisFileDirectory)/../tools/dotnet-getdocument.dll --project %(FullPath)</Command>
<Configuration Condition="'%(Configuration)' == ''">$(Configuration)</Configuration>
<GenerateDefaultDocumentOptions
Condition="'%(GenerateDefaultDocumentOptions)' == ''">$(GenerateDefaultDocumentDefaultOptions)</GenerateDefaultDocumentOptions>
</CurrentServiceProjectReference>
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
<Command>%(Command) --framework %(ProjectTargetFramework)</Command>
<Command>%(Command) --framework %(TargetFramework) --output %(DocumentPath)</Command>
</CurrentServiceProjectReference>
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
<Command Condition="'%(Method)' != ''">%(Command) --method %(Method)</Command>
@ -195,11 +196,15 @@
<Command Condition="'%(Service)' != ''">%(Command) --service %(Service)</Command>
</CurrentServiceProjectReference>
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
<Command>%(Command) --configuration %(ProjectConfiguration) %(DefaultDocumentGeneratorOptions)</Command>
<Command
Condition="'%(ProjectExtensionsPath)' != ''">%(Command) --projectExtensionsPath %(ProjectExtensionsPath)</Command>
</CurrentServiceProjectReference>
<CurrentServiceProjectReference Update="@(CurrentServiceProjectReference)">
<Command>%(Command) --configuration %(Configuration) %(GenerateDefaultDocumentOptions)</Command>
</CurrentServiceProjectReference>
</ItemGroup>
<Message Importance="high" Text="%0ADefaultDocumentGenerator:" />
<Message Importance="high" Text="%0AGenerateDefaultDocument:" />
<Message Importance="high" Text=" %(CurrentServiceProjectReference.Command)" />
<Exec Command="%(CurrentServiceProjectReference.Command)"
IgnoreExitCode="$([System.IO.File]::Exists('%(DocumentPath)'))" />
@ -207,7 +212,7 @@
<!-- ServiceUriReference support -->
<Target Name="_ServiceUriReferenceGenerator_GetMetadata" Condition="'@(ServiceUriReference)' != ''">
<Target Name="_GetMetadataForServiceUriReferences" Condition="'@(ServiceUriReference)' != ''">
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
@ -223,12 +228,12 @@
</ItemGroup>
</Target>
<Target Name="_ServiceUriReferenceGenerator_Core" Condition="'@(ServiceUriReference)' != ''">
<Microsoft.Extensions.ApiDescription.Client.DownloadFile Uri="%(ServiceUriReference.Identity)"
<Target Name="_GenerateServiceUriReferenceDocuments" Condition="'@(ServiceUriReference)' != ''">
<Microsoft.Extensions.ApiDescription.Tasks.DownloadFile Uri="%(ServiceUriReference.Identity)"
DestinationPath="%(DocumentPath)"
Overwrite="$(ServiceUriReferenceCheckIfNewer)" />
<!-- _ServiceUriReferenceGenerator_GetMetadata guarantees %(DocumentPath) values are unique. -->
<!-- GetUriReferenceMetadata task guarantees %(DocumentPath) values are unique. -->
<ItemGroup>
<ServiceFileReference Remove="@(ServiceUriReference -> '%(DocumentPath)')" />
<ServiceFileReference Include="@(ServiceUriReference -> '%(DocumentPath)')">
@ -237,11 +242,12 @@
</ItemGroup>
</Target>
<Target Name="ServiceUriReferenceGenerator" DependsOnTargets="$(ServiceUriReferenceGeneratorDependsOn)" />
<Target Name="GenerateServiceUriReferenceDocuments"
DependsOnTargets="$(GenerateServiceUriReferenceDocumentsDependsOn)" />
<!-- ServiceFileReference support -->
<Target Name="_ServiceFileReferenceGenerator_GetMetadata" Condition="'@(ServiceFileReference)' != ''">
<Target Name="_GetMetadataForServiceFileReferences" Condition="'@(ServiceFileReference)' != ''">
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
@ -260,28 +266,27 @@
</ItemGroup>
</Target>
<Target Name="_ServiceFileReferenceGenerator_GetItems">
<Target Name="_GetCurrentServiceFileReference">
<GetCurrentItems Input="$(GeneratorMetadata)">
<Output TaskParameter="Outputs" ItemName="CurrentServiceFileReference" />
</GetCurrentItems>
</Target>
<Target Name="_ServiceFileReferenceGenerator_Inner"
DependsOnTargets="_ServiceFileReferenceGenerator_GetItems;$(GeneratorTarget)" />
<Target Name="_GenerateServiceFileReferenceCode"
DependsOnTargets="_GetCurrentServiceFileReference;$(GeneratorTarget)" />
<Target Name="_ServiceFileReferenceGenerator_Core" Inputs="@(ServiceFileReference)" Outputs="%(OutputPath)">
<Target Name="_GenerateServiceFileReferenceCodes" Inputs="@(ServiceFileReference)" Outputs="%(OutputPath)">
<MSBuild BuildInParallel="$(BuildInParallel)"
Projects="$(MSBuildProjectFullPath)"
Properties="GeneratorTargetPath=%(ServiceFileReference.OutputPath);GeneratorTarget=%(CodeGenerator)CodeGenerator;GeneratorMetadata=%(SerializedMetadata)"
Properties="GeneratorTargetPath=%(ServiceFileReference.OutputPath);GeneratorTarget=Generate%(CodeGenerator);GeneratorMetadata=%(SerializedMetadata)"
RemoveProperties="TargetFrameworks"
Targets="_ServiceFileReferenceGenerator_Inner" />
Targets="_GenerateServiceFileReferenceCode" />
</Target>
<Target Name="_ServiceFileReferenceGenerator_SetMetadata" Condition="'@(ServiceFileReference)' != ''">
<Target Name="_CreateCompileItemsForServiceFileReferences" Condition="'@(ServiceFileReference)' != ''">
<!--
While %(DocumentPath) metadata may include duplicates (due to overlaps between ServiceUriReference and
ServiceProjectReference items), _ServiceFileReferenceGenerator_GetMetadata guarantees %(OutputPath) values are
unique.
ServiceProjectReference items), GetFileReferenceMetadata task guarantees %(OutputPath) values are unique.
-->
<ItemGroup>
<_Files Remove="@(_Files)" />
@ -324,7 +329,7 @@
</ItemGroup>
</Target>
<Target Name="ServiceFileReferenceGenerator"
<Target Name="GenerateServiceFileReferenceCodes"
BeforeTargets="BeforeCompile"
DependsOnTargets="$(ServiceFileReferenceGeneratorDependsOn)" />
DependsOnTargets="$(GenerateServiceFileReferenceCodesDependsOn)" />
</Project>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<Target Name="ServiceFileReferenceGenerator" BeforeTargets="BeforeCompile">
<Target Name="GenerateServiceFileReferenceCodes" BeforeTargets="BeforeCompile">
<MsBuild Projects="$(MSBuildProjectFile)"
Targets="ServiceFileReferenceGenerator"
Targets="GenerateServiceFileReferenceCodes"
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0])"
RemoveProperties="TargetFrameworks;RuntimeIdentifier" />
</Target>

View File

@ -10,30 +10,30 @@ using Microsoft.DotNet.Cli.CommandLine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Microsoft.Extensions.ApiDescription.Client.Commands
namespace Microsoft.Extensions.ApiDescription.Tool.Commands
{
internal class InvokeCommand : HelpCommandBase
{
private const string InsideManName = "GetDocument.Insider";
private IList<string> _args;
private CommandOption _configuration;
private CommandOption _framework;
private CommandOption _msbuildprojectextensionspath;
private CommandOption _output;
private CommandOption _project;
private CommandOption _projectExtensionsPath;
private CommandOption _runtime;
private IList<string> _args;
private CommandOption _targetFramework;
public override void Configure(CommandLineApplication command)
{
var options = new ProjectOptions();
options.Configure(command);
_project = options.Project;
_framework = options.Framework;
_configuration = options.Configuration;
_project = options.Project;
_projectExtensionsPath = options.ProjectExtensionsPath;
_runtime = options.Runtime;
_msbuildprojectextensionspath = options.MSBuildProjectExtensionsPath;
_targetFramework = options.TargetFramework;
_output = command.Option("--output <Path>", Resources.OutputDescription);
command.VersionOption("--version", ProductInfo.GetVersion);
@ -52,11 +52,11 @@ namespace Microsoft.Extensions.ApiDescription.Client.Commands
var project = Project.FromFile(
projectFile,
_msbuildprojectextensionspath.Value(),
_framework.Value(),
_projectExtensionsPath.Value(),
_targetFramework.Value(),
_configuration.Value(),
_runtime.Value());
if (!File.Exists(project.AssemblyPath))
if (!File.Exists(project.TargetPath))
{
throw new CommandException(Resources.MustBuild);
}
@ -95,16 +95,16 @@ namespace Microsoft.Extensions.ApiDescription.Client.Commands
if (targetFramework.Version < new Version(2, 0))
{
throw new CommandException(
Resources.FormatNETCoreApp1Project(project.Name, targetFramework.Version));
Resources.FormatNETCoreApp1Project(project.ProjectName, targetFramework.Version));
}
args.Add("exec");
args.Add("--depsFile");
args.Add(project.DepsPath);
args.Add(project.ProjectDepsFilePath);
if (!string.IsNullOrEmpty(project.AssetsPath))
if (!string.IsNullOrEmpty(project.ProjectAssetsFile))
{
using (var reader = new JsonTextReader(File.OpenText(project.AssetsPath)))
using (var reader = new JsonTextReader(File.OpenText(project.ProjectAssetsFile)))
{
var projectAssets = JToken.ReadFrom(reader);
var packageFolders = projectAssets["packageFolders"]
@ -119,10 +119,10 @@ namespace Microsoft.Extensions.ApiDescription.Client.Commands
}
}
if (File.Exists(project.RuntimeConfigPath))
if (File.Exists(project.ProjectRuntimeConfigFilePath))
{
args.Add("--runtimeConfig");
args.Add(project.RuntimeConfigPath);
args.Add(project.ProjectRuntimeConfigFilePath);
}
else if (!string.IsNullOrEmpty(project.RuntimeFrameworkVersion))
{
@ -134,16 +134,16 @@ namespace Microsoft.Extensions.ApiDescription.Client.Commands
break;
case ".NETStandard":
throw new CommandException(Resources.FormatNETStandardProject(project.Name));
throw new CommandException(Resources.FormatNETStandardProject(project.ProjectName));
default:
throw new CommandException(
Resources.FormatUnsupportedFramework(project.Name, targetFramework.Identifier));
Resources.FormatUnsupportedFramework(project.ProjectName, targetFramework.Identifier));
}
args.AddRange(_args);
args.Add("--assembly");
args.Add(project.AssemblyPath);
args.Add(project.TargetPath);
args.Add("--tools-directory");
args.Add(toolsDirectory);
@ -180,7 +180,7 @@ namespace Microsoft.Extensions.ApiDescription.Client.Commands
args.Add("--prefix-output");
}
return Exe.Run(executable, args, project.Directory);
return Exe.Run(executable, args, project.ProjectDirectory);
}
finally
{

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class Exe
{

View File

@ -3,9 +3,9 @@
using System;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.Extensions.ApiDescription.Client.Commands;
using Microsoft.Extensions.ApiDescription.Tool.Commands;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal static class Program
{

View File

@ -8,12 +8,12 @@ using System.IO;
using System.Linq;
using IODirectory = System.IO.Directory;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal class Project
{
private const string ResourceFilename = "ServiceProjectReferenceMetadata.targets";
private const string MSBuildResourceName = "Microsoft.Extensions.ApiDescription.Client." + ResourceFilename;
private const string MSBuildResourceName = "Microsoft.Extensions.ApiDescription.Tool." + ResourceFilename;
private Project()
{
@ -21,35 +21,33 @@ namespace Microsoft.Extensions.ApiDescription.Client
public string AssemblyName { get; private set; }
public string AssemblyPath { get; private set; }
public string AssetsPath { get; private set; }
public string ConfigPath { get; private set; }
public string Configuration { get; private set; }
public string ConfigPath { get; private set; }
public string DefaultDocumentName { get; private set; }
public string DefaultMethod { get; private set; }
public string DefaultService { get; private set; }
public string DepsPath { get; private set; }
public string Directory { get; private set; }
public string ExtensionsPath { get; private set; }
public string Name { get; private set; }
public string OutputPath { get; private set; }
public string Platform { get; private set; }
public string PlatformTarget { get; private set; }
public string RuntimeConfigPath { get; private set; }
public string ProjectAssetsFile { get; private set; }
public string ProjectDepsFilePath { get; private set; }
public string ProjectDirectory { get; private set; }
public string ProjectExtensionsPath { get; private set; }
public string ProjectName { get; private set; }
public string ProjectRuntimeConfigFilePath { get; private set; }
public string RuntimeFrameworkVersion { get; private set; }
@ -59,6 +57,8 @@ namespace Microsoft.Extensions.ApiDescription.Client
public string TargetFrameworkMoniker { get; private set; }
public string TargetPath { get; private set; }
public static Project FromFile(
string projectFile,
string buildExtensionsDirectory,
@ -127,7 +127,9 @@ namespace Microsoft.Extensions.ApiDescription.Client
throw new CommandException(Resources.GetMetadataFailed);
}
metadata = File.ReadLines(metadataPath).Select(l => l.Split(new[] { ':' }, 2))
metadata = File
.ReadLines(metadataPath)
.Select(l => l.Split(new[] { ':' }, 2))
.ToDictionary(s => s[0], s => s[1].TrimStart());
}
finally
@ -143,79 +145,88 @@ namespace Microsoft.Extensions.ApiDescription.Client
DefaultService = metadata[nameof(DefaultService)],
AssemblyName = metadata[nameof(AssemblyName)],
AssemblyPath = metadata[nameof(AssemblyPath)],
AssetsPath = metadata[nameof(AssetsPath)],
Configuration = metadata[nameof(Configuration)],
DepsPath = metadata[nameof(DepsPath)],
Directory = metadata[nameof(Directory)],
ExtensionsPath = metadata[nameof(ExtensionsPath)],
Name = metadata[nameof(Name)],
OutputPath = metadata[nameof(OutputPath)],
Platform = metadata[nameof(Platform)],
PlatformTarget = metadata[nameof(PlatformTarget)] ?? metadata[nameof(Platform)],
RuntimeConfigPath = metadata[nameof(RuntimeConfigPath)],
ProjectAssetsFile = metadata[nameof(ProjectAssetsFile)],
ProjectDepsFilePath = metadata[nameof(ProjectDepsFilePath)],
ProjectDirectory = metadata[nameof(ProjectDirectory)],
ProjectExtensionsPath = metadata[nameof(ProjectExtensionsPath)],
ProjectName = metadata[nameof(ProjectName)],
ProjectRuntimeConfigFilePath = metadata[nameof(ProjectRuntimeConfigFilePath)],
RuntimeFrameworkVersion = metadata[nameof(RuntimeFrameworkVersion)],
RuntimeIdentifier = metadata[nameof(RuntimeIdentifier)],
TargetFramework = metadata[nameof(TargetFramework)],
TargetFrameworkMoniker = metadata[nameof(TargetFrameworkMoniker)],
TargetPath = metadata[nameof(TargetPath)],
};
if (string.IsNullOrEmpty(project.AssemblyPath))
{
throw new CommandException(Resources.FormatGetMetadataValueFailed(nameof(AssemblyPath), "TargetPath"));
}
if (string.IsNullOrEmpty(project.Directory))
{
throw new CommandException(Resources.FormatGetMetadataValueFailed(nameof(Directory), "ProjectDir"));
}
if (string.IsNullOrEmpty(project.OutputPath))
{
throw new CommandException(Resources.FormatGetMetadataValueFailed(nameof(OutputPath), "OutDir"));
throw new CommandException(
Resources.FormatGetMetadataValueFailed(nameof(OutputPath), nameof(OutputPath)));
}
if (!Path.IsPathRooted(project.Directory))
if (string.IsNullOrEmpty(project.ProjectDirectory))
{
project.Directory = Path.GetFullPath(Path.Combine(IODirectory.GetCurrentDirectory(), project.Directory));
throw new CommandException(
Resources.FormatGetMetadataValueFailed(nameof(ProjectDirectory), "MSBuildProjectDirectory"));
}
if (!Path.IsPathRooted(project.AssemblyPath))
if (string.IsNullOrEmpty(project.TargetPath))
{
project.AssemblyPath = Path.GetFullPath(Path.Combine(project.Directory, project.AssemblyPath));
throw new CommandException(
Resources.FormatGetMetadataValueFailed(nameof(TargetPath), nameof(TargetPath)));
}
if (!Path.IsPathRooted(project.ExtensionsPath))
if (!Path.IsPathRooted(project.ProjectDirectory))
{
project.ExtensionsPath = Path.GetFullPath(Path.Combine(project.Directory, project.ExtensionsPath));
project.OutputPath = Path.GetFullPath(
Path.Combine(IODirectory.GetCurrentDirectory(), project.ProjectDirectory));
}
if (!Path.IsPathRooted(project.OutputPath))
{
project.OutputPath = Path.GetFullPath(Path.Combine(project.Directory, project.OutputPath));
project.OutputPath = Path.GetFullPath(Path.Combine(project.ProjectDirectory, project.OutputPath));
}
// Some document generation tools support non-ASP.NET Core projects.
// Thus any of the remaining properties may be empty.
if (!(string.IsNullOrEmpty(project.AssetsPath) || Path.IsPathRooted(project.AssetsPath)))
if (!Path.IsPathRooted(project.ProjectExtensionsPath))
{
project.AssetsPath = Path.GetFullPath(Path.Combine(project.Directory, project.AssetsPath));
project.ProjectExtensionsPath = Path.GetFullPath(
Path.Combine(project.ProjectDirectory, project.ProjectExtensionsPath));
}
var configPath = $"{project.AssemblyPath}.config";
if (!Path.IsPathRooted(project.TargetPath))
{
project.TargetPath = Path.GetFullPath(Path.Combine(project.OutputPath, project.TargetPath));
}
// Some document generation tools support non-ASP.NET Core projects. Any of the remaining properties may
// thus be null empty.
var configPath = $"{project.TargetPath}.config";
if (File.Exists(configPath))
{
project.ConfigPath = configPath;
}
if (!(string.IsNullOrEmpty(project.DepsPath) || Path.IsPathRooted(project.DepsPath)))
if (!(string.IsNullOrEmpty(project.ProjectAssetsFile) || Path.IsPathRooted(project.ProjectAssetsFile)))
{
project.DepsPath = Path.GetFullPath(Path.Combine(project.Directory, project.DepsPath));
project.ProjectAssetsFile = Path.GetFullPath(
Path.Combine(project.ProjectDirectory, project.ProjectAssetsFile));
}
if (!(string.IsNullOrEmpty(project.RuntimeConfigPath) || Path.IsPathRooted(project.RuntimeConfigPath)))
if (!(string.IsNullOrEmpty(project.ProjectDepsFilePath) || Path.IsPathRooted(project.ProjectDepsFilePath)))
{
project.RuntimeConfigPath = Path.GetFullPath(Path.Combine(project.Directory, project.RuntimeConfigPath));
project.ProjectDepsFilePath = Path.GetFullPath(
Path.Combine(project.ProjectDirectory, project.ProjectDepsFilePath));
}
if (!(string.IsNullOrEmpty(project.ProjectRuntimeConfigFilePath) ||
Path.IsPathRooted(project.ProjectRuntimeConfigFilePath)))
{
project.ProjectRuntimeConfigFilePath = Path.GetFullPath(
Path.Combine(project.OutputPath, project.ProjectRuntimeConfigFilePath));
}
return project;

View File

@ -3,27 +3,29 @@
using Microsoft.DotNet.Cli.CommandLine;
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
internal class ProjectOptions
{
public CommandOption Configuration { get; private set; }
public CommandOption Project { get; private set; }
public CommandOption Framework { get; private set; }
public CommandOption Configuration { get; private set; }
public CommandOption ProjectExtensionsPath { get; private set; }
public CommandOption Runtime { get; private set; }
public CommandOption MSBuildProjectExtensionsPath { get; private set; }
public CommandOption TargetFramework { get; private set; }
public void Configure(CommandLineApplication command)
{
Project = command.Option("-p|--project <PROJECT>", Resources.ProjectDescription);
Framework = command.Option("--framework <FRAMEWORK>", Resources.FrameworkDescription);
Configuration = command.Option("--configuration <CONFIGURATION>", Resources.ConfigurationDescription);
Project = command.Option("-p|--project <PROJECT>", Resources.ProjectDescription);
ProjectExtensionsPath = command.Option(
"--projectExtensionsPath <PATH>",
Resources.ProjectExtensionsPathDescription);
Runtime = command.Option("--runtime <RUNTIME_IDENTIFIER>", Resources.RuntimeDescription);
MSBuildProjectExtensionsPath = command.Option("--msbuildprojectextensionspath <PATH>", Resources.ProjectExtensionsDescription);
TargetFramework = command.Option("--framework <FRAMEWORK>", Resources.TargetFrameworkDescription);
}
}
}

View File

@ -1,5 +1,5 @@
// <auto-generated />
namespace Microsoft.Extensions.ApiDescription.Client
namespace Microsoft.Extensions.ApiDescription.Tool
{
using System.Globalization;
using System.Reflection;
@ -8,7 +8,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
internal static class Resources
{
private static readonly ResourceManager _resourceManager
= new ResourceManager("Microsoft.Extensions.ApiDescription.Client.Resources", typeof(Resources).GetTypeInfo().Assembly);
= new ResourceManager("Microsoft.Extensions.ApiDescription.Tool.Resources", typeof(Resources).GetTypeInfo().Assembly);
/// <summary>
/// The configuration to use.
@ -41,19 +41,19 @@ namespace Microsoft.Extensions.ApiDescription.Client
/// <summary>
/// The target framework.
/// </summary>
internal static string FrameworkDescription
internal static string TargetFrameworkDescription
{
get => GetString("FrameworkDescription");
get => GetString("TargetFrameworkDescription");
}
/// <summary>
/// The target framework.
/// </summary>
internal static string FormatFrameworkDescription()
=> GetString("FrameworkDescription");
internal static string FormatTargetFrameworkDescription()
=> GetString("TargetFrameworkDescription");
/// <summary>
/// Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --msbuildprojectextensionspath option.
/// Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --projectExtensionsPath option.
/// </summary>
internal static string GetMetadataFailed
{
@ -61,7 +61,7 @@ namespace Microsoft.Extensions.ApiDescription.Client
}
/// <summary>
/// Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --msbuildprojectextensionspath option.
/// Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --projectExtensionsPath option.
/// </summary>
internal static string FormatGetMetadataFailed()
=> GetString("GetMetadataFailed");
@ -195,16 +195,16 @@ namespace Microsoft.Extensions.ApiDescription.Client
/// <summary>
/// The MSBuild project extensions path. Defaults to "obj".
/// </summary>
internal static string ProjectExtensionsDescription
internal static string ProjectExtensionsPathDescription
{
get => GetString("ProjectExtensionsDescription");
get => GetString("ProjectExtensionsPathDescription");
}
/// <summary>
/// The MSBuild project extensions path. Defaults to "obj".
/// </summary>
internal static string FormatProjectExtensionsDescription()
=> GetString("ProjectExtensionsDescription");
internal static string FormatProjectExtensionsPathDescription()
=> GetString("ProjectExtensionsPathDescription");
/// <summary>
/// The runtime identifier to use.

View File

@ -123,11 +123,11 @@
<data name="CommandFullName" xml:space="preserve">
<value>dotnet-getdocument</value>
</data>
<data name="FrameworkDescription" xml:space="preserve">
<data name="TargetFrameworkDescription" xml:space="preserve">
<value>The target framework.</value>
</data>
<data name="GetMetadataFailed" xml:space="preserve">
<value>Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --msbuildprojectextensionspath option.</value>
<value>Unable to retrieve project metadata. If you are using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, use the --projectExtensionsPath option.</value>
</data>
<data name="MultipleProjects" xml:space="preserve">
<value>More than one project was found in the current working directory. Use the --project option.</value>
@ -156,7 +156,7 @@
<data name="ProjectDescription" xml:space="preserve">
<value>The project to use.</value>
</data>
<data name="ProjectExtensionsDescription" xml:space="preserve">
<data name="ProjectExtensionsPathDescription" xml:space="preserve">
<value>The MSBuild project extensions path. Defaults to "obj".</value>
</data>
<data name="RuntimeDescription" xml:space="preserve">
@ -181,6 +181,6 @@
<value>The file to write the result to.</value>
</data>
<data name="GetMetadataValueFailed" xml:space="preserve">
<value>Unable to retrieve '{0}' project metadata. Ensure '{1}' is set.</value>
<value>Unable to retrieve '{0}' project metadata. Ensure '$({1})' is set.</value>
</data>
</root>

View File

@ -11,21 +11,21 @@
<ServiceProjectReferenceMetadata Include="DefaultService: $(DefaultServiceProjectService)" />
<ServiceProjectReferenceMetadata Include="AssemblyName: $(AssemblyName)" />
<ServiceProjectReferenceMetadata Include="AssemblyPath: $(TargetPath)" />
<ServiceProjectReferenceMetadata Include="AssetsPath: $(ProjectAssetsFile)" />
<ServiceProjectReferenceMetadata Include="Configuration: $(Configuration)" />
<ServiceProjectReferenceMetadata Include="DepsPath: $(ProjectDepsFilePath)" />
<ServiceProjectReferenceMetadata Include="Directory: $(ProjectDir)" />
<ServiceProjectReferenceMetadata Include="ExtensionsPath: $(MSBuildProjectExtensionsPath)" />
<ServiceProjectReferenceMetadata Include="Name: $(MSBuildProjectName)" />
<ServiceProjectReferenceMetadata Include="OutputPath: $(OutDir)" />
<ServiceProjectReferenceMetadata Include="OutputPath: $(OutputPath)" />
<ServiceProjectReferenceMetadata Include="Platform: $(Platform)" />
<ServiceProjectReferenceMetadata Include="PlatformTarget: $(PlatformTarget)" />
<ServiceProjectReferenceMetadata Include="RuntimeConfigPath: $(ProjectRuntimeConfigFilePath)" />
<ServiceProjectReferenceMetadata Include="ProjectAssetsFile: $(ProjectAssetsFile)" />
<ServiceProjectReferenceMetadata Include="ProjectDepsFilePath: $(ProjectDepsFilePath)" />
<ServiceProjectReferenceMetadata Include="ProjectDirectory: $(MSBuildProjectDirectory)" />
<ServiceProjectReferenceMetadata Include="ProjectExtensionsPath: $(MSBuildProjectExtensionsPath)" />
<ServiceProjectReferenceMetadata Include="ProjectName: $(MSBuildProjectName)" />
<ServiceProjectReferenceMetadata Include="ProjectRuntimeConfigFilePath: $(ProjectRuntimeConfigFilePath)" />
<ServiceProjectReferenceMetadata Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)" />
<ServiceProjectReferenceMetadata Include="RuntimeIdentifier: $(RuntimeIdentifier)" />
<ServiceProjectReferenceMetadata Include="TargetFramework: $(TargetFramework)" />
<ServiceProjectReferenceMetadata Include="TargetFrameworkMoniker: $(TargetFrameworkMoniker)" />
<ServiceProjectReferenceMetadata Include="TargetPath: $(TargetPath)" />
</ItemGroup>
</Target>

View File

@ -5,7 +5,7 @@
<EnableApiCheck>false</EnableApiCheck>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.Extensions.ApiDescription.Client</RootNamespace>
<RootNamespace>Microsoft.Extensions.ApiDescription.Tool</RootNamespace>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>