Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2018 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
| Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 |
Development editors: Cynthia Kane, Kristen WattersonReview editor: Aleksandar DragosavljeviTechnical development editor: Mike ShepardProject manager: Kevin SullivanCopyeditor: Andy CarrollProofreader: Melody DolabTechnical proofreader: Ricardo PeresTypesetter and cover designer: Marija TudorIllustrator: Chuck Larson
ISBN 9781617294273
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 DP 23 22 21 20 19 18
Brief Table of Contents
Table of Contents
Foreword
.NET Core is what weve always asked for as .NET developers: an open source, fast, and portable runtime for C#, VB, F#, and more. The book youre holding is a great on-ramp to the world of .NET and .NET Core. Youll learn the why, what, and how of building systems on this new platform. Youll utilize a host of open source libraries to test your code, access databases, build microservices, and ultimately go live! Youll also learn how to debug and profile real code in the real world with practical tips and a pragmatic perspective.
.NET Core brings the Common Language Runtime not just to Windows, but also to Mac, Linux, and beyond. You can run .NET Core in a Docker container on an ARM-based Raspberry Pi if it makes you happy! You can code against the .NET Standard and create libraries that can be shared among all these platforms as well as iOS, Android, and even an Apple Watch.
.NET Core is yours and mine, and Im thrilled youre joining us on this adventure. The .NET community has rallied alongside .NET Core like nothing weve seen before in the Microsoft development community. Over half the pull requests for the .NET Core framework come from outside Microsoft! You can run .NET Core apps in Azure, Amazon, Google, and more. Large-scale open source container orchestrators such as Kubernetes can build sophisticated hybrid systems that include all the languages that make you productiveall running side by side on the OS of your choice.
S COTT H ANSELMAN
P RINCIPAL P ROGRAM M ANAGER , .NET, M ICROSOFT
Preface
Software developers keep learning throughout their careers. Its part of the appeal of the field. The more I learn, the more I discover how much I dont know (the known unknown). The times when I learned the most were the times when an unknown unknown became a known unknownwhen a whole category of development was revealed to me that I hadnt heard of before. Subjects such as performance profiling and localization never even occurred to me when I started out. Yet they have an important role in professional software development.
With so much information available through blogs, tweets, Stack Overflow, conferences, and online documentation, some may wonder if physical books can still be relevant, especially with a subject like .NET Core, where the book may be outdated by the time it reaches print. I believe the true value of a book, what gives it lasting impact, is the revelation of the unknown unknown to the reader. The book should cause you to ask questions you havent asked before and provide new context and ways to process the avalanche of information out there on a particular topic.
While this book is about .NET Core, a lot of the concepts have been part of the .NET Framework for years. By opening .NET Core to other platforms, Microsoft hopes to reach a new audience of developers. Im fortunate enough to be in the right place at the right time to write a book that introduces not only .NET Core but also some important aspects of software engineering and how theyre accomplished in the .NET ecosystem. Its my goal with this book to make you a better developer and pique your curiosity about aspects of software engineering you may not have thought about before.
A significant portion of my career has been spent on .NET. My introduction to .NET happened while I was working as a consultant for enterprise resource planning (ERP) systems. A salesman for the consulting company didnt know (or care) that our web ERP portal product was written in Java. The customer liked the portal but wanted to customize it and to use .NET. We worked to rebuild the portal in .NET in a few months and collaborated with the customers development team on their customizations. That turned out to be my favorite consulting job. Years later, I was fortunate enough to be hired by Microsoft and work on the .NET Framework itself. I got to work with many talented developers and wrote code now used by countless applications.
When .NET Core started, I was excited about its potential and got involved early. An editor at Manning saw some of my early work and gave me the opportunity to submit a proposal and table of contents. Id always wanted to write a book, so I jumped at the chance. It takes a special kind of navet to think you have time to write a book after the birth of a child and after taking a larger lead role at work. Not only that, but .NET Core was a moving target in the beginning, which resulted in my having to throw out or rewrite finished chapters and parts of the table of contents.
This book took way longer to write than I expected. But I learned a lot along the way, and Im pleased with the result. Im also proud that I was able to deliver most of the ambitious table of contents I originally planned. I hope you finish this book not only with the ability to write and publish libraries and applications in .NET Core, but also with a desire to learn more.
Acknowledgments
This book wouldnt have been possible without the support of my wife, Sherry. Our son is a handful sometimes, so I really appreciate you giving me time to write. I doubt I would have finished without your encouragement.
Thanks also to the editors at Manning who kept the bar high and helped me write the book I wanted to write: Kristen Watterson, for guiding me to production; Cynthia Kane, for helping me through writing most of the manuscript; Mark Renfrow, for getting me to my first MEAP release; and Greg Wild, for giving me the chance to write this book and some useful advice along the way.