Skip to content

Commit d9fc46e

Browse files
authored
dotnet-svcutil: update NamedPipeMetadataImporter to remove the internal asset folder. (#5582)
* dotnet-svcutil: update NamedPipeMetadataImporter to remove the internal asset folder. * Remove unnecessary package branding properties. * Update folder name from internalAssets to dependencies. * update: directly packaging without copying NamedPipeMetadataImporter binary. * update. * Update: handle 6.0 and 8.0 target framework projects properly. * update.
1 parent aa1eb8f commit d9fc46e

14 files changed

+77
-26
lines changed

dotnet-svcutil.sln

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil", "src\dotne
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-svcutil-lib.Tests", "src\dotnet-svcutil\lib\tests\src\dotnet-svcutil-lib.Tests.csproj", "{41376AC5-871E-4CAB-BCF9-1D5CD3351A90}"
1111
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Svcutil.NamedPipeMetadataImporter", "src\dotnet-svcutil\lib\Microsoft.Svcutil.NamedPipeMetadataImporter\Microsoft.Svcutil.NamedPipeMetadataImporter.csproj", "{0EAB34F1-983D-4E18-B052-BDBE100DA83F}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
2729
{41376AC5-871E-4CAB-BCF9-1D5CD3351A90}.Debug|Any CPU.Build.0 = Debug|Any CPU
2830
{41376AC5-871E-4CAB-BCF9-1D5CD3351A90}.Release|Any CPU.ActiveCfg = Release|Any CPU
2931
{41376AC5-871E-4CAB-BCF9-1D5CD3351A90}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{0EAB34F1-983D-4E18-B052-BDBE100DA83F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{0EAB34F1-983D-4E18-B052-BDBE100DA83F}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{0EAB34F1-983D-4E18-B052-BDBE100DA83F}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{0EAB34F1-983D-4E18-B052-BDBE100DA83F}.Release|Any CPU.Build.0 = Release|Any CPU
3036
EndGlobalSection
3137
GlobalSection(SolutionProperties) = preSolution
3238
HideSolutionNode = FALSE
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net462</TargetFrameworks>
2+
<PropertyGroup>
3+
<AssemblyVersionFile>$(IntermediateOutputPath)\$(TargetFramework)\$(MSBuildProjectName).$(TargetFramework).version.cs</AssemblyVersionFile>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<TargetFrameworks>net6.0;net8.0;net462</TargetFrameworks>
47
<RootNamespace>Microsoft.Tools.ServiceModel.Svcutil</RootNamespace>
58
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
69
<LangVersion>latest</LangVersion>
7-
</PropertyGroup>
8-
<ItemGroup>
9-
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="6.0.*" Condition="'$(TargetFramework)' == 'net6.0'">
10-
<PrivateAssets>contentfiles;analyzers;build</PrivateAssets>
11-
</PackageReference>
10+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
11+
</PropertyGroup>
12+
<ItemGroup>
13+
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="6.*" Condition="'$(TargetFramework)' == 'net6.0'">
14+
<IncludeAssets>all</IncludeAssets>
15+
</PackageReference>
16+
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="8.*" Condition="'$(TargetFramework)' == 'net8.0'">
17+
<IncludeAssets>all</IncludeAssets>
18+
</PackageReference>
1219
<Reference Include="System.ServiceModel" Condition="'$(TargetFramework)' == 'net462'" />
13-
</ItemGroup>
20+
</ItemGroup>
21+
<PropertyGroup>
22+
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
23+
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
24+
<IncludeSymbols>true</IncludeSymbols>
25+
<IncludeSource>false</IncludeSource>
26+
</PropertyGroup>
1427
</Project>

src/dotnet-svcutil/lib/Microsoft.Svcutil.NamedPipeMetadataImporter/NamedPipeMetadataImporter.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ public class NamedPipeMetadataImporter
1717
const string BindingNamespace = "http://schemas.microsoft.com/ws/2005/02/mex/bindings";
1818
XmlReader _xmlReader;
1919

20-
#if NET6_0
20+
#if NET6_0_OR_GREATER
2121
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
2222
#endif
2323
public XmlReader GetReader(Uri uri)
2424
{
2525
return GetMetadatadataAsync(uri).GetAwaiter().GetResult();
2626
}
2727

28-
#if NET6_0
28+
#if NET6_0_OR_GREATER
2929
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
3030
#endif
3131
public async Task<XmlReader> GetMetadatadataAsync(Uri uri)
@@ -77,7 +77,7 @@ public void RequestCallback(IAsyncResult result)
7777
}
7878
}
7979

80-
#if NET6_0
80+
#if NET6_0_OR_GREATER
8181
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
8282
#endif
8383
public CustomBinding CreateNamedPipeBinding()

src/dotnet-svcutil/lib/src/CodeDomFixup/WcfCodeGenerationExtension.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public void WsdlImported(WsdlImporter importer, Collection<ServiceEndpoint> endp
6262

6363
foreach (var binding in bindings)
6464
{
65-
if (binding is NetNamedPipeBinding && _options.Project != null && !_options.Project.TargetFrameworks.Any(t => t.ToLower().Contains("windows")))
65+
if (binding is NetNamedPipeBinding && _options.Project != null && (!_options.Project.TargetFrameworks.Any(t => t.ToLower().Contains("windows"))
66+
|| !_options.Project.TargetFrameworks.Any(t => TargetFrameworkHelper.IsSupportedFramework(t, out FrameworkInfo fxInfo) && fxInfo.Version.Major >= 6)))
6667
{
6768
MetadataConversionError error = new MetadataConversionError(SR.WrnTargetFrameworkNotSupported_NetNamedPipe, isWarning: true);
6869
if (!importer.Errors.Contains(error))

src/dotnet-svcutil/lib/src/Metadata/ServiceDescriptor.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ public async Task ImportMetadataAsync(Action<WsdlImporter> onWsdlImporterCreated
107107
}
108108
else
109109
{
110-
tfn = "net6.0";
110+
tfn = Environment.Version.Major >= 8 ? "net8.0" : "net6.0";
111111
}
112112

113113
string toolPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
114-
Assembly assembly = Assembly.LoadFrom($"{toolPath}/internalAssets/{tfn}/Microsoft.Svcutil.NamedPipeMetadataImporter.dll");
114+
Assembly assembly = Assembly.LoadFrom($"{toolPath}/{tfn}/Microsoft.Svcutil.NamedPipeMetadataImporter.dll");
115115

116116
Type type = assembly.GetType("Microsoft.Tools.ServiceModel.Svcutil.NamedPipeMetadataImporter");
117117
if (type != null)

src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs

+19-4
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,29 @@ public bool AddDependency(ProjectDependency dependency, bool copyInternalAssets
567567

568568
if(copyInternalAssets && dependency.AssemblyName == "dotnet-svcutil-lib")
569569
{
570-
switch(dependency.DependencyType)
570+
string basePath;
571+
string[] frameworks = { "net6.0", "net8.0", "net462" };
572+
switch (dependency.DependencyType)
571573
{
572574
case ProjectDependencyType.Binary:
573-
this.ReferenceGroup.Add(new XElement("Content", new XAttribute("CopyToOutputDirectory", "always"), new XAttribute("Include", Path.Combine(dependency.FullPath.Substring(0, dependency.FullPath.LastIndexOf(Path.DirectorySeparatorChar)), "internalAssets\\**")), new XAttribute("Link", "internalAssets/%(RecursiveDir)%(Filename)%(Extension)")));
575+
basePath = dependency.FullPath.Substring(0, dependency.FullPath.LastIndexOf(Path.DirectorySeparatorChar));
576+
foreach (var framework in frameworks)
577+
{
578+
this.ReferenceGroup.Add(new XElement("Content",
579+
new XAttribute("CopyToOutputDirectory", "always"),
580+
new XAttribute("Include", Path.Combine(basePath, $"{framework}\\**")),
581+
new XAttribute("Link", $"{framework}/%(RecursiveDir)%(Filename)%(Extension)")));
582+
}
574583
break;
575584
case ProjectDependencyType.Package:
576-
string path = $"$(NuGetPackageRoot){dependency.Name}\\{dependency.Version}\\content\\internalAssets\\**";
577-
this.PacakgeReferenceGroup.Add(new XElement("Content", new XAttribute("CopyToOutputDirectory", "always"), new XAttribute("Include", path), new XAttribute("Link", "internalAssets/%(RecursiveDir)%(Filename)%(Extension)")));
585+
basePath = $"$(NuGetPackageRoot){dependency.Name}\\{dependency.Version}";
586+
foreach (var framework in frameworks)
587+
{
588+
this.PacakgeReferenceGroup.Add(new XElement("Content",
589+
new XAttribute("CopyToOutputDirectory", "always"),
590+
new XAttribute("Include", $"{basePath}\\{framework}\\**"),
591+
new XAttribute("Link", $"{framework}/%(RecursiveDir)%(Filename)%(Extension)")));
592+
}
578593
break;
579594
}
580595
}

src/dotnet-svcutil/lib/src/dotnet-svcutil-lib.csproj

+8-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@
6565
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
6666
<PackageReference Include="System.Reflection.DispatchProxy" Version="4.4.0" />
6767
</ItemGroup>
68-
68+
69+
<Target Name="PackAdditonalDlls" AfterTargets="build">
70+
<ItemGroup>
71+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net6.0\*.dll" Pack="true" PackagePath="net6.0"/>
72+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net8.0\*.dll" Pack="true" PackagePath="net8.0"/>
73+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net462\*.dll" Pack="true" PackagePath="net462"/>
74+
</ItemGroup>
75+
</Target>
6976
<!-- Include resx files here so that arcade will handle them correctly. -->
7077
<ItemGroup>
7178
<EmbeddedResource Update="Bootstrapper\Resource.resx">
@@ -119,10 +126,4 @@
119126
<ClassName>System.Web.Services.ResWebServices</ClassName>
120127
</EmbeddedResource>
121128
</ItemGroup>
122-
<ItemGroup>
123-
<Content Include="internalAssets\**">
124-
<Link>internalAssets/%(RecursiveDir)%(Filename)%(Extension)</Link>
125-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
126-
</Content>
127-
</ItemGroup>
128129
</Project>

src/dotnet-svcutil/src/dotnet-svcutil.csproj

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,22 @@
2727
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2828
</PropertyGroup>
2929

30-
30+
<Target Name="PackAdditonalDlls" AfterTargets="build">
31+
<ItemGroup>
32+
<TargetFrameworkItems Include="$(TargetFrameworks)" />
33+
</ItemGroup>
34+
<ItemGroup>
35+
<TargetFrameworkItem Include="%(TargetFrameworkItems.Identity)">
36+
<Tfx>%(TargetFrameworkItems.Identity)</Tfx>
37+
</TargetFrameworkItem>
38+
</ItemGroup>
39+
<ItemGroup>
40+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net6.0\*.dll" Pack="true" PackagePath="tools\%(TargetFrameworkItem.Tfx)\any\net6.0"/>
41+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net8.0\*.dll" Pack="true" PackagePath="tools\%(TargetFrameworkItem.Tfx)\any\net8.0"/>
42+
<None Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)\'))\Microsoft.Svcutil.NamedPipeMetadataImporter\$(Configuration)\net462\*.dll" Pack="true" PackagePath="tools\%(TargetFrameworkItem.Tfx)\any\net462"/>
43+
</ItemGroup>
44+
</Target>
45+
3146
<ItemGroup>
3247
<ProjectReference Include="..\lib\src\dotnet-svcutil-lib.csproj" />
3348
</ItemGroup>

0 commit comments

Comments
 (0)