A quick announcement for anyone using the pre-release MyGet NuGet packages that we’ve now upgraded the major version to v5.0.0.
Currently the major structural changes include:
- All NuGet packages have a 5.0.0 Version
- All .Core packages are merged into the main ServiceStack NuGet packages and share the same v5 version number
- All .NET Standard or PCL builds have been upgraded to .NET Standard 2.0
- All .NET 4.5 .dll versions are now strong named with the
servicestack.snk
key that’s in the /src of each repo. ServiceStack.Logging.Elmah is the only .NET 4.5 dll that’s not signed because itselmah.corelibrary
dep is unsigned.
We’ve rewritten the PCL client builds to use the .NET Standard 2.0 APIs which now supports Xamarin iOS/Android. v5 also support UWP but .NET Standard 2.0 but this requires upgrading to Windows 10 Fall Creators Update. There’s no longer any Silverlight or Windows Phone builds which end at v4.5.14 on NuGet, v5 is still wire-compatible so if you’re still maintaining legacy Silverlight or Windows Phone Apps your v4.5.14 clients can consume v5 Services as before.
Currently if you’re using the MyGet builds:
- You’ll need to upgrade your ServiceStack dependencies to the major
5.0.0
version or use a5.*
wildcard. - If you were using the Signed packages you’ll need to remove the
.Signed
suffix - If you’re using .NET Core you’ll need to remove the
.Core
suffix on each package.
FluentValidation
We’ve upgraded our internal implementation to use the latest version FluentValidation 7.2
.NET Core IAppSettings Adapter
You can use the new NetCoreAppSettings
adapter to utilize .NET Core’s new IConfiguration
config model in ServiceStack by injecting .NET Core’s pre-configured IConfiguration
injected into the Startup
constructor when you register your AppHost, e.g:
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration) => Configuration = configuration;
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseServiceStack(new AppHost
{
AppSettings = new NetCoreAppSettings(Configuration)
});
}
}
This will let you use appsettings.json
and .NET Core’s other Configuration Sources in ServiceStack under the IAppSettings
API which works as you’d expect where you can get both primitive values and complex Types with Get<T>
, e.g:
bool debug = AppSettings.Get<bool>("DebugMode", false);
MyConfig myConfig = AppSettings.Get<MyConfig>();
We’ve switched all our .NET Core 2.0 SPA projects to use the above .NET Core configuration model, e.g. here’s the react-spa source code.
New Password Hashing implementation
We’re now using the same PBKDF2 password hashing algorithm ASP.NET Identity v3 uses to hash passwords by default for both new users and successful authentication logins where their password will be re-hashed with the new implementation automatically. You can revert to using the existing SaltedHash
implementation with:
SetConfig(new HostConfig {
UseSaltedHash = true
});
This also supports “downgrading” passwords that were hashed with the new IPasswordHasher
provider where it will revert to using the older/weaker SaltedHash implementation on successful authentication.
Digest Auth Hashes only created when needed
We’re also only maintaining Digest Auth Hashes if the DigestAuthProvider
is registered. If you ever intend to support Digest access authentication in future but don’t want to register the DigestAuthProvider
just yet, you can force ServiceStack to maintain Digest Auth Hashes with:
new AuthFeature {
CreateDigestAuthHashes = true
}
Users that don’t have Digest Auth Hashes will require logging in again in order to populate it. If you don’t intend to use Digest Auth you can clear the DigestHa1Hash
column in your UserAuth
table which is otherwise unused.
Features that need to be explicitly registered
SOAP Support is now opt-in, if you need it you’ll need to register:
Plugins.Add(new SoapFormat());
Markdown Razor and MiniProfiler are also opt-in and have been moved to different projects below:
Separate NuGet package for .NET Framework specific features
We’re aiming to make the primary ServiceStack.dll and NuGet Package containing core functionality that’s applicable to all Hosts, i.e. ASP.NET, HttpListener and .NET Core so we’ve started moving ASP.NET/HttpListener specific features to different packages but we’re keeping the same namespaces/type names to ensure maximum source compatibility.
ServiceStack.Razor
The HTML Helpers for ServiceStack Razor has been moved to the ServiceStack.Razor project. This should be a transparent change as you needed ServiceStack.Razor to make use of them.
MarkdownFormat and Markdown Razor has also been moved to ServiceStack.Razor. Since this was built on Code DOM it can’t run on .NET Core and was stripped down to bare Markdown functionality. This was previously pre-registered by default, if you were using it you’ll now need to explicitly register it, e.g:
Plugins.Add(new MarkdownFormat());
Also ServiceStack Templates is a much superior, cleaner, faster and more flexible alternative to Markdown Razor where its most redeeming feature of being able to mix .NET in Markdown can be easily be achieved using Transformers.
ServiceStack.NetFramework
ServiceStack.NetFramework is a new project/NuGet package where we’re maintaining .NET Framework only features. This currently contains MiniProfiler which now needs to be explicitly registered with:
Plugins.Add(new MiniProfilerFeature());
And SmartThreadPool which is an internal ThreadPool to provide a faster alternative to .NET’s built-in ThreadPool. The fastest self-hosting option is now to use a .NET Core App instead of HttpListener which also runs flawlessly cross-platform so it’s our recommended option for new projects if you don’t have any requirements requiring use of the .NET Framework. The primary result of this is that now AppSelfHostBase is implemented using AppHostHttpListenerPoolBase
. If you want to revert your HttpListener AppHost back to using a SmartThreadPool impl, change your AppHost to inherit either SmartThreadPool.AppSelfHostBase
or AppHostHttpListenerSmartPoolBase
, e.g:
public class AppHost : SmartThreadPool.AppSelfHostBase {}
public class AppHost : AppHostHttpListenerSmartPoolBase {}
New .NET Core 2.0 SPA Templates
We’ve developed new Webpack-powered .NET Core 2.0 SPA Templates which uses the pre-release version of ServiceStack v5 which are available from: https://github.com/NetCoreTemplates/
You can use the dotnet-new script included as part of @servicestack/cli project to create projects from the different templates.
You’ll need to have the latest @servicestack/cli v1.0.0
installed. If you had a previous version you’ll need to remove it:
npm uninstall -g @servicestack/cli
npm uninstall -g servicestack-cli # old npm package name
Before installing it again to get the latest version:
npm install -g @servicestack/cli
This will make the dotnet-new
script available which you can use to view all the available templates by running it without any arguments:
$ dotnet-new
Which at this time displays:
You can then create a project from one of the templates, e.g:
$ dotnet-new vue-spa Acme
Which will generate a new project with the folder names and source files replaced with your project name, e.g:
You can run then run the Acme.sln
in VS2017 which will automatically restore and install both the .NET and npm packages when first loaded. This can take a bit of time to install everything, once it’s finished you’ll see the wwwroot
folder populated with your generated Webpack app which includes a dist
folder and index.html
page. After these are generated you can run your App with F5 as normal.
If you’re using JetBrains Rider you can install npm packages by opening package.json
and run the “npm install” tooltip on the bottom right. In VS Code you’ll need to run npm install
from the command-line.
To develop your App, our preference would be to run Webpack watch on the command-line with:
$ npm run dev
Which will watch and re-compile your App for any changes. These new templates also include a new hot-reload feature which works similar to ServiceStack Templates hot-reloading where in DebugMode it will long poll the server every 60s for any modified files in wwwroot
and automatically refresh the page. This provides a hot-reload alternative to npm run dev-server
to run a Webpack Dev Server proxy on port http://localhost:3000
The new Templates is similar to ServiceStack’s .NET 4.5 Webpack SPA Templates except it’s been modified to use Webpack’s DllPlugin for faster build times.
For publishing / deployments we just make use of .NET Core’s dotnet publish
feature which you can run with:
$ npm run publish
Which will generate a production optimized build and dotnet Release build in the bin/Release/netcoreapp2.0/publish
output folder, which you can then xcopy/rsync to any deployment server similar to deploying .NET Core 2.0 Web Apps.
All the template features are available as both npm scripts and gulp scripts (which just call the npm scripts), which you can run with:
npm run <script-name>
Which currently includes:
npm run watch
npm run build
npm run build-prod
npm run build-vendor
npm run publish
npm run test
npm run test-watch
npm run typescript-ref
npm run dev
That should get you up an running. If you find any issues with ServiceStack v5 of the new Templates please let us know!