WireMock.Net.WebApplication.NETCore3
@@ -47,8 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.StandAlone.NET
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net452", "examples\WireMock.Net.StandAlone.Net452\WireMock.Net.StandAlone.Net452.csproj", "{668F689E-57B4-422E-8846-C0FF643CA999}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net452", "examples\WireMock.Net.StandAlone.Net452\WireMock.Net.StandAlone.Net452.csproj", "{668F689E-57B4-422E-8846-C0FF643CA999}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication\WireMock.Net.WebApplication.NETCore2.csproj", "{049539C1-7A66-4559-AD7A-B1C73B97CBB0}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.Net452", "examples\WireMock.Net.Console.Proxy.Net452\WireMock.Net.Console.Proxy.Net452.csproj", "{26433A8F-BF01-4962-97EB-81BFFBB61096}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.Net452", "examples\WireMock.Net.Console.Proxy.Net452\WireMock.Net.Console.Proxy.Net452.csproj", "{26433A8F-BF01-4962-97EB-81BFFBB61096}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net461", "examples\WireMock.Net.StandAlone.Net461\WireMock.Net.StandAlone.Net461.csproj", "{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net461", "examples\WireMock.Net.StandAlone.Net461\WireMock.Net.StandAlone.Net461.csproj", "{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}"
|
||||||
@@ -69,6 +67,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.OpenApiParser.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.FluentAssertions", "src\WireMock.Net.FluentAssertions\WireMock.Net.FluentAssertions.csproj", "{B6269AAC-170A-4346-8B9A-579DED3D9A95}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore2", "examples\WireMock.Net.WebApplication.NETCore2\WireMock.Net.WebApplication.NETCore2.csproj", "{6F38CB3A-6DA1-408A-AECD-E434523C2838}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication.NETCore3", "examples\WireMock.Net.WebApplication.NETCore3\WireMock.Net.WebApplication.NETCore3.csproj", "{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -123,10 +125,6 @@ Global
|
|||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{668F689E-57B4-422E-8846-C0FF643CA999}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.Build.0 = Release|Any CPU
|
{668F689E-57B4-422E-8846-C0FF643CA999}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@@ -167,6 +165,14 @@ Global
|
|||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B6269AAC-170A-4346-8B9A-579DED3D9A95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6F38CB3A-6DA1-408A-AECD-E434523C2838}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -184,7 +190,6 @@ Global
|
|||||||
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{1995E414-F197-4AB4-90C2-68D806B5AF59} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{10E16614-61CA-48D8-8BDD-664C13913DED} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{10E16614-61CA-48D8-8BDD-664C13913DED} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{668F689E-57B4-422E-8846-C0FF643CA999} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{668F689E-57B4-422E-8846-C0FF643CA999} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{049539C1-7A66-4559-AD7A-B1C73B97CBB0} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
|
||||||
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
@@ -195,6 +200,8 @@ Global
|
|||||||
{D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
{D3804228-91F4-4502-9595-39584E5AADAD} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
{5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
{5C09FB93-1535-4F92-AF26-21E8A061EE4A} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
{B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
{B6269AAC-170A-4346-8B9A-579DED3D9A95} = {8F890C6F-9ACC-438D-928A-AD61CDA862F2}
|
||||||
|
{6F38CB3A-6DA1-408A-AECD-E434523C2838} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
|
{E1C56967-3DC7-46CB-A1DF-B13167A0D9D4} = {985E0ADB-D4B4-473A-AA40-567E279B7946}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
SolutionGuid = {DC539027-9852-430C-B19F-FD035D018458}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace WireMock.Net.WebApplication
|
namespace WireMock.Net.WebApplication
|
||||||
{
|
{
|
||||||
public class App
|
public class App
|
||||||
{
|
{
|
||||||
private readonly IWireMockService _service;
|
private readonly IWireMockService _service;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public App(IWireMockService service, ILogger logger)
|
public App(IWireMockService service, ILogger logger)
|
||||||
{
|
{
|
||||||
_service = service;
|
_service = service;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("WireMock.Net App running");
|
_logger.LogInformation("WireMock.Net App running");
|
||||||
_service.Run();
|
_service.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace WireMock.Net.WebApplication
|
namespace WireMock.Net.WebApplication
|
||||||
{
|
{
|
||||||
public interface IWireMockService
|
public interface IWireMockService
|
||||||
{
|
{
|
||||||
void Run();
|
void Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,38 +1,38 @@
|
|||||||
{
|
{
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iis": {
|
"iis": {
|
||||||
"applicationUrl": "http://localhost//wiremock",
|
"applicationUrl": "http://localhost//wiremock",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
},
|
},
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:56513/",
|
"applicationUrl": "http://localhost:56513/",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchUrl": "__admin/settings",
|
"launchUrl": "__admin/settings",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"WireMock.Net.WebApplication": {
|
"WireMock.Net.WebApplication": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "__admin/settings",
|
"launchUrl": "__admin/settings",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"applicationUrl": "http://localhost:56514/"
|
"applicationUrl": "http://localhost:56514/"
|
||||||
},
|
},
|
||||||
"IIS": {
|
"IIS": {
|
||||||
"commandName": "IIS",
|
"commandName": "IIS",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "development"
|
"ASPNETCORE_ENVIRONMENT": "development"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"defaultProvider": "cdnjs",
|
"defaultProvider": "cdnjs",
|
||||||
"libraries": []
|
"libraries": []
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
# Running in IIS
|
# Running in IIS
|
||||||
|
|
||||||
Follow these links / steps:
|
Follow these links / steps:
|
||||||
* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
|
* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
|
||||||
* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1
|
* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1
|
||||||
* Create a `web.config` file
|
* Create a `web.config` file
|
||||||
|
|
||||||
## IIS Sites
|
## IIS Sites
|
||||||

|

|
||||||
|
|
||||||
## App Pool settings
|
## App Pool settings
|
||||||

|

|
||||||
|
|
||||||
## Publish Profiles
|
## Publish Profiles
|
||||||
Two example publish profiles are created:
|
Two example publish profiles are created:
|
||||||
* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml)
|
* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml)
|
||||||
* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml)
|
* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml)
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
Select the debug "IIS" if you want to debug in IIS.
|
Select the debug "IIS" if you want to debug in IIS.
|
||||||

|

|
||||||
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!--
|
<!--
|
||||||
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
|
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
|
||||||
-->
|
-->
|
||||||
<system.webServer>
|
<system.webServer>
|
||||||
<handlers>
|
<handlers>
|
||||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
|
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
|
||||||
</handlers>
|
</handlers>
|
||||||
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
|
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
</configuration>
|
</configuration>
|
||||||
22
examples/WireMock.Net.WebApplication.NETCore3/App.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace WireMock.Net.WebApplication
|
||||||
|
{
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
private readonly IWireMockService _service;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public App(IWireMockService service, ILogger logger)
|
||||||
|
{
|
||||||
|
_service = service;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("WireMock.Net App running");
|
||||||
|
_service.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace WireMock.Net.WebApplication
|
||||||
|
{
|
||||||
|
public interface IWireMockService
|
||||||
|
{
|
||||||
|
void Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
59
examples/WireMock.Net.WebApplication.NETCore3/Program.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using WireMock.Settings;
|
||||||
|
// using Microsoft.Extensions.Logging.Console;
|
||||||
|
|
||||||
|
namespace WireMock.Net.WebApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
// Create service collection
|
||||||
|
var serviceCollection = new ServiceCollection();
|
||||||
|
ConfigureServices(serviceCollection);
|
||||||
|
|
||||||
|
// Create service provider
|
||||||
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
|
|
||||||
|
// Run app
|
||||||
|
serviceProvider.GetService<App>().Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(IServiceCollection serviceCollection)
|
||||||
|
{
|
||||||
|
// Build configuration
|
||||||
|
var configuration = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(AppContext.BaseDirectory)
|
||||||
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.AddEnvironmentVariables() // <-- this is needed to to override settings via the Azure Portal App Settings
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
// Add LoggerFactory
|
||||||
|
var factory = new LoggerFactory();
|
||||||
|
//var consoleLog = new ConsoleLoggerProvider(configuration.GetSection("Logging"));
|
||||||
|
serviceCollection.AddSingleton(factory
|
||||||
|
// .AddProvider(configuration.GetSection("Logging"))
|
||||||
|
// .AddDebug()
|
||||||
|
// .AddAzureWebAppDiagnostics()
|
||||||
|
);
|
||||||
|
|
||||||
|
serviceCollection.AddSingleton(factory.CreateLogger("WireMock.Net Logger"));
|
||||||
|
|
||||||
|
// Add access to generic IConfigurationRoot
|
||||||
|
serviceCollection.AddSingleton(configuration);
|
||||||
|
|
||||||
|
// Add access to WireMockServerSettings
|
||||||
|
var settings = configuration.GetSection("WireMockServerSettings").Get<WireMockServerSettings>();
|
||||||
|
serviceCollection.AddSingleton<WireMockServerSettings>(settings);
|
||||||
|
|
||||||
|
// Add services
|
||||||
|
serviceCollection.AddTransient<IWireMockService, WireMockService>();
|
||||||
|
|
||||||
|
// Add app
|
||||||
|
serviceCollection.AddTransient<App>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iis": {
|
||||||
|
"applicationUrl": "http://localhost//wiremock",
|
||||||
|
"sslPort": 0
|
||||||
|
},
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:56513/",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchUrl": "__admin/settings",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WireMock.Net.WebApplication": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "__admin/settings",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "http://localhost:56514/"
|
||||||
|
},
|
||||||
|
"IIS": {
|
||||||
|
"commandName": "IIS",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
||||||
|
<StartupObject>WireMock.Net.WebApplication.Program</StartupObject>
|
||||||
|
<AssemblyName>WireMock.Net.WebApplication</AssemblyName>
|
||||||
|
<RootNamespace>WireMock.Net.WebApplication</RootNamespace>
|
||||||
|
<UserSecretsId>efcf4a18-fd7c-4622-1111-336d65290599</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!--<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />-->
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
|
||||||
|
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using WireMock.Admin.Requests;
|
||||||
|
using WireMock.Logging;
|
||||||
|
using WireMock.Server;
|
||||||
|
using WireMock.Settings;
|
||||||
|
|
||||||
|
namespace WireMock.Net.WebApplication
|
||||||
|
{
|
||||||
|
public class WireMockService : IWireMockService
|
||||||
|
{
|
||||||
|
private static int sleepTime = 30000;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly WireMockServerSettings _settings;
|
||||||
|
|
||||||
|
private class Logger : IWireMockLogger
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public Logger(ILogger logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Debug(string formatString, params object[] args)
|
||||||
|
{
|
||||||
|
_logger.LogDebug(formatString, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Info(string formatString, params object[] args)
|
||||||
|
{
|
||||||
|
_logger.LogInformation(formatString, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Warn(string formatString, params object[] args)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(formatString, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Error(string formatString, params object[] args)
|
||||||
|
{
|
||||||
|
_logger.LogError(formatString, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest)
|
||||||
|
{
|
||||||
|
string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented);
|
||||||
|
_logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Error(string formatString, Exception exception)
|
||||||
|
{
|
||||||
|
_logger.LogError(formatString, exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WireMockService(ILogger logger, WireMockServerSettings settings)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_settings = settings;
|
||||||
|
|
||||||
|
_settings.Logger = new Logger(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("WireMock.Net server starting");
|
||||||
|
|
||||||
|
WireMockServer.Start(_settings);
|
||||||
|
|
||||||
|
_logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}");
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("WireMock.Net server running");
|
||||||
|
Thread.Sleep(sleepTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"IncludeScopes": false,
|
||||||
|
"Debug": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Console": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WireMockServerSettings": {
|
||||||
|
"AdminUsername": "a",
|
||||||
|
"AdminPassword": "b",
|
||||||
|
"StartAdminInterface": true
|
||||||
|
}
|
||||||
|
}
|
||||||
21
examples/WireMock.Net.WebApplication.NETCore3/readme.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Running in IIS
|
||||||
|
|
||||||
|
Follow these links / steps:
|
||||||
|
* https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
|
||||||
|
* https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1
|
||||||
|
* Create a `web.config` file
|
||||||
|
|
||||||
|
## IIS Sites
|
||||||
|

|
||||||
|
|
||||||
|
## App Pool settings
|
||||||
|

|
||||||
|
|
||||||
|
## Publish Profiles
|
||||||
|
Two example publish profiles are created:
|
||||||
|
* [IIS Localhost 1](./Properties/PublishProfiles/IIS%20Localhost%201.pubxml)
|
||||||
|
* [IIS Localhost 2](./Properties/PublishProfiles/IIS%20Localhost%202.pubxml)
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
Select the debug "IIS" if you want to debug in IIS.
|
||||||
|

|
||||||
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 14 KiB |
12
examples/WireMock.Net.WebApplication.NETCore3/web.config
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!--
|
||||||
|
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
|
||||||
|
-->
|
||||||
|
<system.webServer>
|
||||||
|
<handlers>
|
||||||
|
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||||
|
</handlers>
|
||||||
|
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess" />
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
|
|
||||||
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<WebPublishMethod>MSDeploy</WebPublishMethod>
|
|
||||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
|
||||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
|
||||||
<SiteUrlToLaunchAfterPublish />
|
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
|
||||||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
|
||||||
<ProjectGuid>049539c1-7a66-4559-ad7a-b1c73b97cbb0</ProjectGuid>
|
|
||||||
<SelfContained>true</SelfContained>
|
|
||||||
<_IsPortable>false</_IsPortable>
|
|
||||||
<MSDeployServiceURL>localhost</MSDeployServiceURL>
|
|
||||||
<DeployIisAppPath>Default Web Site/wiremock1</DeployIisAppPath>
|
|
||||||
<RemoteSitePhysicalPath />
|
|
||||||
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
|
|
||||||
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
|
|
||||||
<EnableMSDeployBackup>False</EnableMSDeployBackup>
|
|
||||||
<UserName />
|
|
||||||
<_SavePWD>False</_SavePWD>
|
|
||||||
<PublishDatabaseSettings>
|
|
||||||
<Objects xmlns="" />
|
|
||||||
</PublishDatabaseSettings>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
|
|
||||||
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<WebPublishMethod>MSDeploy</WebPublishMethod>
|
|
||||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
|
||||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
|
||||||
<SiteUrlToLaunchAfterPublish />
|
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
|
||||||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
|
||||||
<ProjectGuid>049539c1-7a66-4559-ad7a-b1c73b97cbb1</ProjectGuid>
|
|
||||||
<SelfContained>true</SelfContained>
|
|
||||||
<_IsPortable>false</_IsPortable>
|
|
||||||
<MSDeployServiceURL>localhost</MSDeployServiceURL>
|
|
||||||
<DeployIisAppPath>Default Web Site/wiremock2</DeployIisAppPath>
|
|
||||||
<RemoteSitePhysicalPath />
|
|
||||||
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
|
|
||||||
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
|
|
||||||
<EnableMSDeployBackup>False</EnableMSDeployBackup>
|
|
||||||
<UserName />
|
|
||||||
<_SavePWD>False</_SavePWD>
|
|
||||||
<PublishDatabaseSettings>
|
|
||||||
<Objects xmlns="" />
|
|
||||||
</PublishDatabaseSettings>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||