Skip to content

Commit eaafad3

Browse files
authored
Merge pull request #17 from sharwell/netstandard1
Support .NET Standard 1.x
2 parents d912cff + e184e78 commit eaafad3

File tree

1 file changed

+113
-8
lines changed

1 file changed

+113
-8
lines changed

TunnelVisionLabs.ReferenceAssemblyAnnotator/TunnelVisionLabs.ReferenceAssemblyAnnotator.targets

Lines changed: 113 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,59 @@
7676
<Target Name="RestoreTargetFrameworkDirectory"
7777
Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'"
7878
BeforeTargets="ResolveAvailableReferenceAssemblies">
79-
<ItemGroup>
79+
<ItemGroup Condition="'$(NETStandardLibraryPackageVersion)' == ''">
80+
<!-- .NET Standard 1.x -->
81+
<_NetStandardReferences Include="@(Reference)"
82+
Condition="
83+
'%(NuGetPackageId)' == 'Microsoft.Win32.Primitives'
84+
OR '%(NuGetPackageId)' == 'XXXSystem.AppContext'
85+
OR '%(NuGetPackageId)' == 'System.Collections'
86+
OR '%(NuGetPackageId)' == 'System.Collections.Concurrent'
87+
OR '%(NuGetPackageId)' == 'XXXSystem.Console'
88+
OR '%(NuGetPackageId)' == 'System.Diagnostics.Debug'
89+
OR '%(NuGetPackageId)' == 'System.Diagnostics.Tools'
90+
OR '%(NuGetPackageId)' == 'System.Diagnostics.Tracing'
91+
OR '%(NuGetPackageId)' == 'System.Globalization'
92+
OR '%(NuGetPackageId)' == 'System.Globalization.Calendars'
93+
OR '%(NuGetPackageId)' == 'System.IO'
94+
OR '%(NuGetPackageId)' == 'System.IO.Compression'
95+
OR '%(NuGetPackageId)' == 'System.IO.Compression.ZipFile'
96+
OR '%(NuGetPackageId)' == 'XXXSystem.IO.FileSystem'
97+
OR '%(NuGetPackageId)' == 'XXXSystem.IO.FileSystem.Primitives'
98+
OR '%(NuGetPackageId)' == 'System.Linq'
99+
OR '%(NuGetPackageId)' == 'System.Linq.Expressions'
100+
OR '%(NuGetPackageId)' == 'System.Net.Http'
101+
OR '%(NuGetPackageId)' == 'System.Net.Primitives'
102+
OR '%(NuGetPackageId)' == 'System.Net.Sockets'
103+
OR '%(NuGetPackageId)' == 'System.ObjectModel'
104+
OR '%(NuGetPackageId)' == 'System.Reflection'
105+
OR '%(NuGetPackageId)' == 'System.Reflection.Extensions'
106+
OR '%(NuGetPackageId)' == 'System.Reflection.Primitives'
107+
OR '%(NuGetPackageId)' == 'System.Resources.ResourceManager'
108+
OR '%(NuGetPackageId)' == 'System.Runtime'
109+
OR '%(NuGetPackageId)' == 'System.Runtime.Extensions'
110+
OR '%(NuGetPackageId)' == 'System.Runtime.Handles'
111+
OR '%(NuGetPackageId)' == 'System.Runtime.InteropServices'
112+
OR '%(NuGetPackageId)' == 'System.Runtime.InteropServices.RuntimeInformation'
113+
OR '%(NuGetPackageId)' == 'System.Runtime.Numerics'
114+
OR '%(NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Algorithms'
115+
OR '%(NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Encoding'
116+
OR '%(NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Primitives'
117+
OR '%(NuGetPackageId)' == 'XXXSystem.Security.Cryptography.X509Certificates'
118+
OR '%(NuGetPackageId)' == 'System.Text.Encoding'
119+
OR '%(NuGetPackageId)' == 'System.Text.Encoding.Extensions'
120+
OR '%(NuGetPackageId)' == 'System.Text.RegularExpressions'
121+
OR '%(NuGetPackageId)' == 'System.Threading'
122+
OR '%(NuGetPackageId)' == 'System.Threading.Tasks'
123+
OR '%(NuGetPackageId)' == 'System.Threading.Timer'
124+
OR '%(NuGetPackageId)' == 'System.Xml.ReaderWriter'
125+
OR '%(NuGetPackageId)' == 'System.Xml.XDocument'" />
126+
<_NetStandardNuGetPackageFoldersNoSlash Include="$([System.IO.Path]::GetDirectoryName('%(_NetStandardReferences.Identity)'))" />
127+
<_NetStandardNuGetPackageFolders Include="$([MSBuild]::NormalizeDirectory('%(_NetStandardNuGetPackageFoldersNoSlash.Identity)'))" />
128+
</ItemGroup>
129+
130+
<ItemGroup Condition="'$(NETStandardLibraryPackageVersion)' != ''">
131+
<!-- .NET Standard 2+ -->
80132
<_NuGetPackageFoldersItems Include="$(NuGetPackageFolders)" />
81133
<_NetStandardNuGetPackageFolders Include="$([MSBuild]::NormalizeDirectory('%(_NuGetPackageFoldersItems.Identity)', 'netstandard.library', '$(NETStandardLibraryPackageVersion)', 'build', 'netstandard2.0', 'ref'))" />
82134
</ItemGroup>
@@ -106,12 +158,64 @@
106158
<!-- Automatically annotate .NET Standard assemblies -->
107159
<Target Name="AddStandardAssembliesForAnnotation"
108160
BeforeTargets="ResolveOutputReferenceAssemblies">
109-
<ItemGroup>
110-
<UnannotatedReferenceAssembly Include="@(Reference->'%(FileName)')"
111-
Condition="'%(Reference.NuGetPackageId)' == 'NETStandard.Library' AND Exists('$(AnnotatedReferenceAssemblyDirectory)%(Reference.FileName)%(Reference.Extension)')"
112-
OriginalReference="%(Reference.Identity)"
113-
IsNetStandard="True" />
114-
</ItemGroup>
161+
<ItemGroup Condition="'$(NETStandardLibraryPackageVersion)' == ''">
162+
<!-- .NET Standard 1.x -->
163+
<UnannotatedReferenceAssembly Include="@(Reference->'%(FileName)')"
164+
Condition="Exists('$(AnnotatedReferenceAssemblyDirectory)%(Reference.FileName)%(Reference.Extension)')
165+
AND ('%(Reference.NuGetPackageId)' == 'Microsoft.Win32.Primitives'
166+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.AppContext'
167+
OR '%(Reference.NuGetPackageId)' == 'System.Collections'
168+
OR '%(Reference.NuGetPackageId)' == 'System.Collections.Concurrent'
169+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.Console'
170+
OR '%(Reference.NuGetPackageId)' == 'System.Diagnostics.Debug'
171+
OR '%(Reference.NuGetPackageId)' == 'System.Diagnostics.Tools'
172+
OR '%(Reference.NuGetPackageId)' == 'System.Diagnostics.Tracing'
173+
OR '%(Reference.NuGetPackageId)' == 'System.Globalization'
174+
OR '%(Reference.NuGetPackageId)' == 'System.Globalization.Calendars'
175+
OR '%(Reference.NuGetPackageId)' == 'System.IO'
176+
OR '%(Reference.NuGetPackageId)' == 'System.IO.Compression'
177+
OR '%(Reference.NuGetPackageId)' == 'System.IO.Compression.ZipFile'
178+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.IO.FileSystem'
179+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.IO.FileSystem.Primitives'
180+
OR '%(Reference.NuGetPackageId)' == 'System.Linq'
181+
OR '%(Reference.NuGetPackageId)' == 'System.Linq.Expressions'
182+
OR '%(Reference.NuGetPackageId)' == 'System.Net.Http'
183+
OR '%(Reference.NuGetPackageId)' == 'System.Net.Primitives'
184+
OR '%(Reference.NuGetPackageId)' == 'System.Net.Sockets'
185+
OR '%(Reference.NuGetPackageId)' == 'System.ObjectModel'
186+
OR '%(Reference.NuGetPackageId)' == 'System.Reflection'
187+
OR '%(Reference.NuGetPackageId)' == 'System.Reflection.Extensions'
188+
OR '%(Reference.NuGetPackageId)' == 'System.Reflection.Primitives'
189+
OR '%(Reference.NuGetPackageId)' == 'System.Resources.ResourceManager'
190+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime'
191+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime.Extensions'
192+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime.Handles'
193+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime.InteropServices'
194+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime.InteropServices.RuntimeInformation'
195+
OR '%(Reference.NuGetPackageId)' == 'System.Runtime.Numerics'
196+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Algorithms'
197+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Encoding'
198+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.Security.Cryptography.Primitives'
199+
OR '%(Reference.NuGetPackageId)' == 'XXXSystem.Security.Cryptography.X509Certificates'
200+
OR '%(Reference.NuGetPackageId)' == 'System.Text.Encoding'
201+
OR '%(Reference.NuGetPackageId)' == 'System.Text.Encoding.Extensions'
202+
OR '%(Reference.NuGetPackageId)' == 'System.Text.RegularExpressions'
203+
OR '%(Reference.NuGetPackageId)' == 'System.Threading'
204+
OR '%(Reference.NuGetPackageId)' == 'System.Threading.Tasks'
205+
OR '%(Reference.NuGetPackageId)' == 'System.Threading.Timer'
206+
OR '%(Reference.NuGetPackageId)' == 'System.Xml.ReaderWriter'
207+
OR '%(Reference.NuGetPackageId)' == 'System.Xml.XDocument')"
208+
OriginalReference="%(Reference.Identity)"
209+
IsNetStandard="True" />
210+
</ItemGroup>
211+
212+
<ItemGroup Condition="'$(NETStandardLibraryPackageVersion)' != ''">
213+
<!-- .NET Standard 2+ -->
214+
<UnannotatedReferenceAssembly Include="@(Reference->'%(FileName)')"
215+
Condition="'%(Reference.NuGetPackageId)' == 'NETStandard.Library' AND Exists('$(AnnotatedReferenceAssemblyDirectory)%(Reference.FileName)%(Reference.Extension)')"
216+
OriginalReference="%(Reference.Identity)"
217+
IsNetStandard="True" />
218+
</ItemGroup>
115219
</Target>
116220

117221
<Target Name="UpdateNetStandardAssemblies"
@@ -121,7 +225,8 @@
121225
<Reference Remove="%(UnannotatedReferenceAssembly.OriginalReference)"
122226
Condition="'%(UnannotatedReferenceAssembly.IsNetStandard)' == 'True' AND Exists('%(UnannotatedReferenceAssembly.OutputAssembly)')" />
123227
<Reference Include="@(UnannotatedReferenceAssembly->'%(OutputAssembly)')"
124-
Condition="'%(UnannotatedReferenceAssembly.IsNetStandard)' == 'True' AND Exists('%(UnannotatedReferenceAssembly.OutputAssembly)')" />
228+
Condition="'%(UnannotatedReferenceAssembly.IsNetStandard)' == 'True' AND Exists('%(UnannotatedReferenceAssembly.OutputAssembly)')"
229+
HintPath="" />
125230
</ItemGroup>
126231
</Target>
127232

0 commit comments

Comments
 (0)