Skip to content

Commit 41f3ec1

Browse files
committed
update service
1 parent 9b7cade commit 41f3ec1

File tree

7 files changed

+37
-34
lines changed

7 files changed

+37
-34
lines changed

NuGet.config

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<clear />
55
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
66
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
7+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
78
</packageSources>
89
<auditSources>
910
<clear />

eng/SendToHelix.proj

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.DotNet.Helix.Sdk" InitialTargets="InstallDotNet;Test">
1+
<Project Sdk="Microsoft.DotNet.Helix.Sdk" InitialTargets="InstallDotNet;BuildProjects;Test">
22
<PropertyGroup>
33
<HelixSource Condition=" '$(RunAsPublic)' == 'true' ">pr/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
44
<HelixSource Condition=" '$(RunAsInternal)' == 'true' ">official/dotnet/wcf/$(BUILD_SOURCEBRANCH)/</HelixSource>
@@ -26,10 +26,10 @@
2626
</ItemGroup>
2727
</Target>
2828

29-
<ItemGroup>
30-
<ProjectsToBuild Include="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
31-
</ItemGroup>
32-
29+
<Target Name="BuildProjects">
30+
<MSBuild Targets="Restore;Publish" Projects="..\src\System.Private.ServiceModel\tools\SelfHostedCoreWcfService\SelfHostedCoreWCFService.csproj"/>
31+
</Target>
32+
3333
<ItemGroup>
3434
<XUnitProject Include="..\src\System.Private.ServiceModel\tests\Scenarios\**\*.IntegrationTests.csproj">
3535
<TargetFramework>$(XUnitPublishTargetFramework)</TargetFramework>
@@ -74,24 +74,26 @@
7474
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
7575
</PropertyGroup>
7676

77+
<PropertyGroup>
78+
<HelixPreCommands>$(HelixPreCommands);export _TestJob=$(TestJob);export _RunWithCoreWCFService=$(RunWithCoreWCFService)</HelixPreCommands>
79+
</PropertyGroup>
80+
7781
<PropertyGroup Condition="'$(TestJob)' != 'Windows'" >
7882
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
7983
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
8084
</PropertyGroup>
8185

82-
<PropertyGroup Condition="'$(TestJob)' == 'Windows'">
86+
<PropertyGroup Condition="'$(TestJob)' == 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
8387
<HelixPreCommands>$(HelixPreCommands);set PATH=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli%3B%PATH%</HelixPreCommands>
8488
<!-- %3B is an escaped ; -->
8589
<HelixPreCommands>$(HelixPreCommands);set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli;set DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
8690
<HelixPreCommands>$(HelixPreCommands);set DOTNET_CLI_HOME=%HELIX_WORKITEM_ROOT%\.dotnet</HelixPreCommands>
8791
<HelixPreCommands>$(HelixPreCommands);set NUGET_PACKAGES=%HELIX_WORKITEM_ROOT%\.nuget</HelixPreCommands>
8892
<HelixPreCommands>$(HelixPreCommands);set ServiceUri=localhost</HelixPreCommands>
89-
<HelixPreCommands>$(HelixPreCommands);dir C:\ /s /b /o:gn | find "SelfHostedCoreWCFService"</HelixPreCommands>
90-
<HelixPreCommands>$(HelixPreCommands);dir D:\ /s /b /o:gn | find "SelfHostedCoreWCFService"</HelixPreCommands>
9193
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net8.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
9294
</PropertyGroup>
9395

94-
<PropertyGroup Condition="'$(TestJob)' != 'Windows'">
96+
<PropertyGroup Condition="'$(TestJob)' != 'Windows' AND '$(RunWithCoreWCFService)' == 'true'">
9597
<HelixPreCommands>$(HelixPreCommands);export PATH=$HELIX_CORRELATION_PAYLOAD/dotnet-cli:$PATH</HelixPreCommands>
9698
<HelixPreCommands>$(HelixPreCommands);export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/dotnet-cli;export DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
9799
<HelixPreCommands>$(HelixPreCommands);export DOTNET_CLI_HOME=$HELIX_WORKITEM_ROOT/.dotnet</HelixPreCommands>
@@ -100,17 +102,13 @@
100102
<HelixPreCommands>$(HelixPreCommands);dotnet exec --roll-forward Major $HELIX_CORRELATION_PAYLOAD/SelfHostedCoreWCFService/$(Configuration)/net8.0/SelfHostedCoreWCFService.dll bootstrap:true</HelixPreCommands>
101103
</PropertyGroup>
102104

103-
<Target Name="BuildProjects">
104-
<MSBuild Targets="Build" Projects="@(ProjectsToBuild)"/>
105-
</Target>
106-
107105
<ItemGroup>
108106
<!-- Directory that is zipped up and sent as a correlation payload to Helix -->
109107
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\src\System.Private.ServiceModel\tools\scripts'))" >
110108
<PayloadDirectory>%(Identity)</PayloadDirectory>
111109
</HelixCorrelationPayload>
112-
113-
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\artifacts\bin'))" >
110+
111+
<HelixCorrelationPayload Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\artifacts\bin\SelfHostedCoreWCFService'))" >
114112
<Destination>SelfHostedCoreWCFService</Destination>
115113
</HelixCorrelationPayload>
116114
</ItemGroup>

src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/CoreWCF/ServiceHostHelper.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public static async Task ServiceBootstrap()
7777
Environment.Exit(1);
7878
}
7979

80-
public static Enum ToServiceSchema(string CoreWcfScheme) => CoreWcfScheme switch
80+
public static Enum ToServiceSchema(string CoreWcfScheme, bool usesWebsockets) => CoreWcfScheme switch
8181
{
82-
"http" => ServiceSchema.HTTP,
83-
"https" => ServiceSchema.HTTPS,
82+
"http" => usesWebsockets ? ServiceSchema.WS : ServiceSchema.HTTP,
83+
"https" => usesWebsockets ? ServiceSchema.WSS : ServiceSchema.HTTPS,
8484
"net.tcp" => ServiceSchema.NETTCP,
8585
"net.pipe" => ServiceSchema.NETPIPE,
8686
"ws" => ServiceSchema.WS,

src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/TestDefinitionHelper.cs

+16-13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Net;
88
using System.Security.Claims;
99
using System.Security.Cryptography.X509Certificates;
10+
using CoreWCF.Channels;
1011
using CoreWCF.Configuration;
1112
using CoreWCF.Description;
1213
using idunno.Authentication.Basic;
@@ -41,17 +42,11 @@ internal static IDictionary<ServiceSchema, string> BaseAddresses
4142
dict[ServiceSchema.HTTPS] = string.Format(@"https://localhost:{0}", httpsPort);
4243
var tcpPort = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("tcpPort")) ? DefaultTcpPort : int.Parse(Environment.GetEnvironmentVariable("tcpPort"));
4344
dict[ServiceSchema.NETTCP] = string.Format(@"net.tcp://localhost:{0}", tcpPort);
44-
#if NET
45-
var websocketPort = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("websocketPort")) ? DefaultWebSocketPort : int.Parse(Environment.GetEnvironmentVariable("websocketPort"));
46-
dict[ServiceSchema.WS] = string.Format(@"ws://localhost:{0}", websocketPort);
47-
var websocketsPort = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("websocketsPort")) ? DefaultWebSocketSPort : int.Parse(Environment.GetEnvironmentVariable("websocketsPort"));
48-
dict[ServiceSchema.WSS] = string.Format(@"wss://localhost:{0}", websocketsPort);
49-
#else
5045
var websocketPort = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("websocketPort")) ? DefaultWebSocketPort : int.Parse(Environment.GetEnvironmentVariable("websocketPort"));
5146
dict[ServiceSchema.WS] = string.Format(@"http://localhost:{0}", websocketPort);
5247
var websocketsPort = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("websocketsPort")) ? DefaultWebSocketSPort : int.Parse(Environment.GetEnvironmentVariable("websocketsPort"));
5348
dict[ServiceSchema.WSS] = string.Format(@"https://localhost:{0}", websocketsPort);
54-
#endif
49+
5550
s_baseAddresses = dict;
5651
dict[ServiceSchema.NETPIPE] = @"net.pipe://localhost";
5752
Console.WriteLine("Using base addresses:");
@@ -149,7 +144,7 @@ internal static async Task StartHosts()
149144
.Configure(app =>
150145
{
151146
app.UseAuthentication();
152-
app.UseAuthorization();
147+
app.UseAuthorization();
153148
app.UseServiceModel(serviceBuilder =>
154149
{
155150
foreach (var serviceTestHost in GetAttributedServiceHostTypes())
@@ -194,18 +189,26 @@ internal static async Task StartHosts()
194189
var serviceHost = (ServiceHost)Activator.CreateInstance(serviceTestHost, serviceTestHostOptionsDict[serviceHostTypeName].serviceBaseAddresses.ToArray());
195190
serviceBuilder.AddService(serviceHost.ServiceType, options =>
196191
{
197-
var localHostTypeName = serviceHostTypeName;
198192
options.BaseAddresses.Clear();
199-
foreach (var baseAddress in BaseAddresses.Values)
193+
foreach (var baseAddress in BaseAddresses)
200194
{
201-
//if (!options.BaseAddresses.Contains(baseAddress))
202-
options.BaseAddresses.Add(new Uri(baseAddress));
195+
if ((BaseAddresses.ContainsKey(ServiceSchema.HTTP) && baseAddress.Key == ServiceSchema.WS) ||
196+
(BaseAddresses.ContainsKey(ServiceSchema.HTTPS) && baseAddress.Key == ServiceSchema.WSS))
197+
{
198+
continue;
199+
}
200+
201+
options.BaseAddresses.Add(new Uri(baseAddress.Value));
203202
}
204203
});
205204

206205
foreach (var endpoint in serviceHost.Endpoints)
207206
{
208-
Enum schema = ServiceHostHelper.ToServiceSchema(endpoint.Binding.Scheme);
207+
var customBinding = new CustomBinding(endpoint.Binding);
208+
var htbe = customBinding.Elements.Find<HttpTransportBindingElement>();
209+
bool usesWebsockets = htbe != null && htbe.WebSocketSettings.TransportUsage == WebSocketTransportUsage.Always;
210+
211+
Enum schema = ServiceHostHelper.ToServiceSchema(endpoint.Binding.Scheme, usesWebsockets);
209212
string basePath = serviceTestHostOptionsDict[serviceHostTypeName].endpointBasePath[schema];
210213
string endpointAddress = string.Format("{0}/{1}", basePath, endpoint.Address);
211214
serviceBuilder.AddServiceEndpoint(serviceHost.ServiceType, endpoint.ContractType, endpoint.Binding, new Uri(endpointAddress, UriKind.RelativeOrAbsolute), null);

src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/HttpsClientCertificateTestServiceHost.cs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace WcfService
1818
{
1919
[TestServiceDefinition(Schema = ServiceSchema.HTTPS, BasePath = "ClientCertificateAccepted/HttpsClientCertificate.svc")]
20+
[TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "ClientCertificateAccepted/HttpsClientCertificate.svc")]
2021
public class HttpsClientCertificateTestServiceHost : TestServiceHostBase<IWcfService>
2122
{
2223
protected override IList<Binding> GetBindings()

src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WebSocketTestServiceHosts.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public class DuplexWebSocketTestServiceHost : TestServiceHostBase<IWcfDuplexServ
2121

2222
protected override Binding GetBinding()
2323
{
24-
return new NetHttpBinding();
24+
NetHttpBinding binding = new NetHttpBinding();
25+
binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always;
26+
return binding;
2527
}
2628

2729
public DuplexWebSocketTestServiceHost(params Uri[] baseAddresses)

src/System.Private.ServiceModel/tools/SelfHostedCoreWcfService/SelfHostedCoreWCFService.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<Compile Remove="..\IISHostedWcfService\App_code\testhosts\Saml2IssuedTokenTestServiceHost.cs" />
3535
<Compile Remove="..\IISHostedWcfService\App_code\testhosts\HttpsTransportSecurityMessageCredentialsCertTestServiceHost.cs" />
3636
<Compile Remove="..\IISHostedWcfService\App_code\testhosts\HttpsTransportSecurityMessageCredentialsUsernameTestServiceHost.cs" />
37-
<Compile Remove="..\IISHostedWcfService\App_code\testhosts\TestHostWebServiceHost.cs" />
3837

3938
<None Include="..\IISHostedWcfService\App_code\testhosts\Federation\AcceptAnyUsernameSecurityTokenHandler.cs" />
4039
<None Include="..\IISHostedWcfService\App_code\testhosts\Federation\FederationSTSServiceHost.cs" />
@@ -46,7 +45,6 @@
4645
<None Include="..\IISHostedWcfService\App_code\testhosts\Saml2IssuedTokenTestServiceHost.cs" />
4746
<None Include="..\IISHostedWcfService\App_code\testhosts\HttpsTransportSecurityMessageCredentialsCertTestServiceHost.cs" />
4847
<None Include="..\IISHostedWcfService\App_code\testhosts\HttpsTransportSecurityMessageCredentialsUsernameTestServiceHost.cs" />
49-
<None Include="..\IISHostedWcfService\App_code\testhosts\TestHostWebServiceHost.cs" />
5048
</ItemGroup>
5149
<ItemGroup>
5250
<None Include="..\IISHostedWcfService\Web.config">

0 commit comments

Comments
 (0)