Skip to content

Commit

Permalink
Generating Source package for System.Text.Json (dotnet/corefx#34552)
Browse files Browse the repository at this point in the history
* Generating Source package for System.Text.Json

* Changing the placeholder file to be in netcoreapp3.0 instead

* Renaming package

* Updating arcade to get new SourceRewriter package

* Fix package location of resource files

* Adding .resx file to the package and addressing PR Feedback

* Adding description and fixing issue with spacing

* Automatically generate targets file that goes in the package


Commit migrated from dotnet/corefx@09b8b4b
  • Loading branch information
joperezr authored Jan 18, 2019
1 parent 5d846e6 commit 2c9532c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
<UsingTask TaskName="GenerateSourceWithPublicTypesAsInternal" AssemblyFile="$(PackagingTaskDir)Microsoft.DotNet.Build.Tasks.Packaging.dll" />

<PropertyGroup>
<!-- We need to make sure that all of the surface area on the sources gets rewritten as internal. -->
<GenerateInternalTypesSource>true</GenerateInternalTypesSource>
</PropertyGroup>

<!-- Given that System.Text.Json has Resources, we need to make sure we include them (and the SR.cs from Common)
on the sources of the package. This target will retrieve the compiled resources file and will also add
the Common SR.cs into SourcePackageFiles. -->
<Target Name="GetSourcesToPackage" BeforeTargets="ExpandProjectReferences">
<ItemGroup>
<_ProjectsToBuild Include="../src/System.Text.Json.csproj" UndefineProperties="Configuration" />
</ItemGroup>

<MSBuild Projects="@(_ProjectsToBuild)"
Targets="GetSourcesToPackage">
<Output TaskParameter="TargetOutputs"
ItemName="SourcePackageFiles" />
</MSBuild>
</Target>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
</Project>
26 changes: 26 additions & 0 deletions src/libraries/System.Text.Json/src/System.Text.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,30 @@
<Reference Include="System.Numerics.Vectors" />
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
</ItemGroup>

<!-- The Source Package will call into this target in order to retrieve the compiled resources file as
it will need to be part of the source package contents. -->
<Target Name="GetSourcesToPackage" Returns="@(_sourceToPackage)" DependsOnTargets="Compile">

<PropertyGroup>
<_sourcePackageTargetLines><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup Condition="'%24(ExcludeEmbeddedResourceFromPackage)' != 'true'">@(EmbeddedResource->'
<EmbeddedResource Include="%24(MSBuildThisFileDirectory)%(FileName)%(Extension)" ManifestResourceName="%(ManifestResourceName)" />', '')
</ItemGroup>
</Project>]]>
</_sourcePackageTargetLines>
<_targetsFileName>Microsoft.Bcl.Json.Sources.targets</_targetsFileName>
<_generatedSourcePackageTargetPath>$(IntermediateOutputPath)/$(_targetsFileName)</_generatedSourcePackageTargetPath>
</PropertyGroup>

<WriteLinesToFile Lines="$(_sourcePackageTargetLines)" File="$(_generatedSourcePackageTargetPath)" Overwrite="True" />

<ItemGroup>
<_sourceToExclude Include="@(Compile)" Condition="$([System.String]::Copy('%(Compile.Identity)').ToLower().EndsWith('assemblyinfo.cs'))" />
<_sourceToPackage Include="@(Compile->'%(FullPath)')" PackagePath="contentFiles/cs/netstandard2.0/%(FileName)%(Extension)" Exclude="@(_sourceToExclude)"/>
<_sourceToPackage Condition="'%(Extension)' == '.resx'" Include="@(EmbeddedResource->'%(FullPath)')" PackagePath="build/netstandard2.0/%(FileName)%(Extension)" />
<_sourceToPackage Include="$(_generatedSourcePackageTargetPath)" PackagePath="build/netstandard2.0/$(_targetsFileName)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"net45": "4.0.0.0"
}
},
"Microsoft.Bcl.Json.Sources": {
"InboxOn": {}
},
"Microsoft.Build": {
"InboxOn": {
"net45": "4.0.0.0"
Expand Down Expand Up @@ -4179,7 +4182,7 @@
],
"BaselineVersion": "4.6.0",
"InboxOn": {
"net45": "4.0.0.0",
"net45": "4.0.0.0",
"net451": "4.0.10.0",
"portable46-win81+wp81+wpa81": "4.0.0.0",
"portable46-win81+wp81": "4.0.0.0",
Expand Down
11 changes: 10 additions & 1 deletion src/libraries/pkg/descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,16 @@
"Name": "System.Text.Json",
"Description": "Provides a fast, non-cached, forward-only way to read UTF-8 encoded JavaScript Object Notation (JSON) text.",
"CommonTypes": [
"System.Text.Json.Utf8JsonReader"
"System.Text.Json.Utf8JsonReader",
"System.Text.Json.Utf8JsonWriter"
]
},
{
"Name": "Microsoft.Bcl.Json.Sources",
"Description": "Provides the source code implementation of System.Text.Json as internal types. This package is only required for projects targeting .NET Framework 4.6.1+ or .NET Core 2.x; and is not for projects that can target .NET Core 3.0 and higher.",
"CommonTypes": [
"System.Text.Json.Utf8JsonReader",
"System.Text.Json.Utf8JsonWriter"
]
},
{
Expand Down

0 comments on commit 2c9532c

Please sign in to comment.