Address immediate issues in service reference feature (#12366)
- #12363 - correct a few VS issues - void silent failures - improve documentation - support the `clean` target - stop using experimentatal package version
This commit is contained in:
parent
470bfddf92
commit
fcb6575f19
|
|
@ -9,7 +9,6 @@
|
||||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||||
<PackageTags>Build Tasks;MSBuild;Swagger;Open API;code generation; Web API client</PackageTags>
|
<PackageTags>Build Tasks;MSBuild;Swagger;Open API;code generation; Web API client</PackageTags>
|
||||||
<IsShippingPackage>true</IsShippingPackage>
|
<IsShippingPackage>true</IsShippingPackage>
|
||||||
<VersionPrefix>$(ExperimentalVersionPrefix)</VersionPrefix>
|
|
||||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||||
<DevelopmentDependency>true</DevelopmentDependency>
|
<DevelopmentDependency>true</DevelopmentDependency>
|
||||||
<HasReferenceAssembly>false</HasReferenceAssembly>
|
<HasReferenceAssembly>false</HasReferenceAssembly>
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,6 @@
|
||||||
Well-known metadata of the code generator item groups.
|
Well-known metadata of the code generator item groups.
|
||||||
-->
|
-->
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<!-- OpenApiProjectReference items may also include OpenApiReference metadata. -->
|
|
||||||
<OpenApiProjectReference />
|
|
||||||
|
|
||||||
<OpenApiReference>
|
<OpenApiReference>
|
||||||
<!-- Name of the class to generate. Defaults to match filename in %(OutputPath). -->
|
<!-- Name of the class to generate. Defaults to match filename in %(OutputPath). -->
|
||||||
<ClassName />
|
<ClassName />
|
||||||
|
|
@ -98,5 +95,40 @@
|
||||||
-->
|
-->
|
||||||
<OutputPath />
|
<OutputPath />
|
||||||
</OpenApiReference>
|
</OpenApiReference>
|
||||||
|
|
||||||
|
<!-- OpenApiProjectReference items may include all OpenApiReference metadata. -->
|
||||||
|
<OpenApiProjectReference>
|
||||||
|
<!--
|
||||||
|
Name of the class to generate. Defaults to match filename in %(OutputPath). To avoid compilation errors,
|
||||||
|
override only if the referenced project has a single registered document.
|
||||||
|
-->
|
||||||
|
<ClassName />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Code generator to use. Required and must end with "CSharp" or "TypeScript" (the currently-supported target
|
||||||
|
languages) unless %(OutputPath) is set. Builds will invoke a target named "Generate%(CodeGenerator)" to do
|
||||||
|
actual code generation.
|
||||||
|
-->
|
||||||
|
<CodeGenerator>NSwagCSharp</CodeGenerator>
|
||||||
|
|
||||||
|
<!-- Namespace to contain generated class. Default is $(RootNamespace). -->
|
||||||
|
<Namespace />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Options to pass to the code generator target then (likely) added to a tool's command line. Value is passed
|
||||||
|
along to the code generator but otherwise unused in this package.
|
||||||
|
-->
|
||||||
|
<Options>$(OpenApiGenerateCodeOptions)</Options>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Path to place generated code. Code generator may interpret path as a filename or directory. Default filename or
|
||||||
|
folder name is {document filename}Client.[cs|ts]. {document filename} is always either %(Filename}.json (when
|
||||||
|
the document name is "v1") or %(Filename)_{document name}.json (otherwise). Filenames and relative paths (if
|
||||||
|
explicitly set) are combined with $(OpenApiCodeDirectory). Final value (depending on $(OpenApiCodeDirectory))
|
||||||
|
is likely to be a path relative to the client project. To avoid repeatedly writing to the same file, override
|
||||||
|
only if the referenced project has a single registered document.
|
||||||
|
-->
|
||||||
|
<OutputPath />
|
||||||
|
</OpenApiProjectReference>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
-->
|
-->
|
||||||
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
|
<ProjectReference Include="@(OpenApiProjectReference)" Exclude="@(ProjectReference)">
|
||||||
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
|
<GlobalPropertiesToRemove>TargetFramework</GlobalPropertiesToRemove>
|
||||||
|
<Private>false</Private>
|
||||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
|
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
|
@ -128,6 +129,9 @@
|
||||||
<SourceDocument>%(_Directories.FullPath)</SourceDocument>
|
<SourceDocument>%(_Directories.FullPath)</SourceDocument>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
||||||
|
<FileWrites Exclude="@(FileWrites)"
|
||||||
|
Include="@(_Files);@(_Directories -> '%(Identity)/**/*.ts;%(Identity)/**/*.tsx;%(Identity)/**/*.$(DefaultLanguageSourceExtension)'" />
|
||||||
|
|
||||||
<_Files Remove="@(_Files)" />
|
<_Files Remove="@(_Files)" />
|
||||||
<_Directories Remove="@(_Directories)" />
|
<_Directories Remove="@(_Directories)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
<StringProperty Name="Link" Visible="false">
|
<StringProperty Name="Link" Visible="false">
|
||||||
<StringProperty.DataSource>
|
<StringProperty.DataSource>
|
||||||
<DataSource SourceOfDefaultValue="AfterContext" />
|
<DataSource SourceOfDefaultValue="AfterContext" PersistenceStyle="Attribute" />
|
||||||
</StringProperty.DataSource>
|
</StringProperty.DataSource>
|
||||||
<StringProperty.Metadata>
|
<StringProperty.Metadata>
|
||||||
<NameValuePair Name="DoNotCopyAcrossProjects" Value="true" />
|
<NameValuePair Name="DoNotCopyAcrossProjects" Value="true" />
|
||||||
|
|
@ -88,6 +88,12 @@
|
||||||
</StringProperty.DataSource>
|
</StringProperty.DataSource>
|
||||||
</StringProperty>
|
</StringProperty>
|
||||||
|
|
||||||
|
<StringProperty Name="CodeGenerator" Visible="false">
|
||||||
|
<StringProperty.DataSource>
|
||||||
|
<DataSource SourceOfDefaultValue="AfterContext" PersistenceStyle="Attribute" />
|
||||||
|
</StringProperty.DataSource>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
<StringProperty Name="Namespace" DisplayName="Namespace"
|
<StringProperty Name="Namespace" DisplayName="Namespace"
|
||||||
Category="CodeGen"
|
Category="CodeGen"
|
||||||
Description="Namespace to place the generated class in.">
|
Description="Namespace to place the generated class in.">
|
||||||
|
|
@ -158,6 +164,12 @@
|
||||||
|
|
||||||
<BoolProperty Name="Visible" Visible="false" Default="true" />
|
<BoolProperty Name="Visible" Visible="false" Default="true" />
|
||||||
|
|
||||||
|
<StringProperty Name="CodeGenerator" Visible="false">
|
||||||
|
<StringProperty.DataSource>
|
||||||
|
<DataSource SourceOfDefaultValue="AfterContext" PersistenceStyle="Attribute" />
|
||||||
|
</StringProperty.DataSource>
|
||||||
|
</StringProperty>
|
||||||
|
|
||||||
<StringProperty Name="Namespace" DisplayName="Namespace"
|
<StringProperty Name="Namespace" DisplayName="Namespace"
|
||||||
Category="CodeGen"
|
Category="CodeGen"
|
||||||
Description="Namespace to place the generated classes in.">
|
Description="Namespace to place the generated classes in.">
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||||
<PackageTags>MSBuild;Swagger;Open API;code generation;Web API</PackageTags>
|
<PackageTags>MSBuild;Swagger;Open API;code generation;Web API</PackageTags>
|
||||||
<IsShippingPackage>true</IsShippingPackage>
|
<IsShippingPackage>true</IsShippingPackage>
|
||||||
<VersionPrefix>$(ExperimentalVersionPrefix)</VersionPrefix>
|
|
||||||
<DevelopmentDependency>true</DevelopmentDependency>
|
<DevelopmentDependency>true</DevelopmentDependency>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup Condition=" '$(OpenApiGenerateDocuments)' == '' ">
|
<PropertyGroup Condition=" '$(OpenApiGenerateDocuments)' == '' ">
|
||||||
<OpenApiGenerateDocuments
|
<OpenApiGenerateDocuments
|
||||||
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' < '2.1' ">false</OpenApiGenerateDocuments>
|
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion.TrimStart('vV'))' < '2.1' ">false</OpenApiGenerateDocuments>
|
||||||
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">true</OpenApiGenerateDocuments>
|
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">true</OpenApiGenerateDocuments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
@ -16,15 +16,24 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="OpenApiGetDocuments" Returns="@(_OpenApiProjectDocuments)">
|
<Target Name="OpenApiGetDocuments" Returns="@(_OpenApiProjectDocuments)">
|
||||||
|
<Error Text="OpenAPI document generation is disabled. Add '<OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>' to the project."
|
||||||
|
Condition=" '$(OpenApiGenerateDocuments)' != 'true' " />
|
||||||
|
|
||||||
<ReadLinesFromFile File="$(_OpenApiDocumentsCache)">
|
<ReadLinesFromFile File="$(_OpenApiDocumentsCache)">
|
||||||
<Output TaskParameter="Lines" ItemName="_OpenApiProjectDocuments" />
|
<Output TaskParameter="Lines" ItemName="_OpenApiProjectDocuments" />
|
||||||
</ReadLinesFromFile>
|
</ReadLinesFromFile>
|
||||||
|
|
||||||
|
<Warning Text="Application does not have any registered documents. Update its 'Startup' class to register a document."
|
||||||
|
Condition=" '@(_OpenApiProjectDocuments)' == '' " />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GenerateOpenApiDocuments"
|
<Target Name="GenerateOpenApiDocuments"
|
||||||
Condition=" '$(OpenApiGenerateDocuments)' == 'true' "
|
Condition=" '$(OpenApiGenerateDocuments)' == 'true' "
|
||||||
Inputs="$(TargetPath)"
|
Inputs="$(TargetPath)"
|
||||||
Outputs="$(_OpenApiDocumentsCache)">
|
Outputs="$(_OpenApiDocumentsCache)">
|
||||||
|
<Error Text="OpenAPI document generation is not supported when targeting netcoreapp2.0 or earlier. Disable the feature or move to a later target framework."
|
||||||
|
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion.TrimStart('vV'))' < '2.1' " />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_Command>dotnet "$(MSBuildThisFileDirectory)/../tools/dotnet-getdocument.dll" --assembly "$(TargetPath)"</_Command>
|
<_Command>dotnet "$(MSBuildThisFileDirectory)/../tools/dotnet-getdocument.dll" --assembly "$(TargetPath)"</_Command>
|
||||||
<_Command>$(_Command) --file-list "$(_OpenApiDocumentsCache)" --framework "$(TargetFrameworkMoniker)"</_Command>
|
<_Command>$(_Command) --file-list "$(_OpenApiDocumentsCache)" --framework "$(TargetFrameworkMoniker)"</_Command>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue