{"id":28070,"date":"2020-05-21T08:00:29","date_gmt":"2020-05-21T15:00:29","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=28070"},"modified":"2020-05-21T15:16:06","modified_gmt":"2020-05-21T22:16:06","slug":"using-visual-studio-codespaces-with-net-core","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/using-visual-studio-codespaces-with-net-core\/","title":{"rendered":"Using Visual Studio Codespaces with .NET Core"},"content":{"rendered":"<p>What a time to be a .NET developer!\u00a0 Lots of great announcements at Build, new releases for .NET Core and new preview projects for cloud native development make me excited to be a .NET developer!<\/p>\n<p>One of the new capabilities <a href=\"https:\/\/aka.ms\/vscs-blog\">we announced at Build was the ability to use Visual Studio 2019 with Codespaces<\/a>.\u00a0 Visual Studio Codespaces is an online development environment that allows you to develop entirely in the cloud.\u00a0 We want all of you to be able to try it out and encourage you to sign up for the private preview we have going right now.\u00a0 Go ahead and <a href=\"https:\/\/aka.ms\/vsfutures-signup\">head over and sign up for early access<\/a>.\u00a0 It\u2019s okay, I\u2019ll wait.<\/p>\n<p>Okay, signed up for the early access?\u00a0 Great, now let me tell you what the .NET team has been working on to enable .NET Core development in Codespaces.\u00a0 We have initially focused our efforts on enabling the core editing, testing, debugging inner loop for .NET Core application types of class libraries, console apps, and web apps (including Web API).\u00a0 At the time of this writing, Windows Forms designer for .NET Core will not be available, however you can still use C# to edit your project code.<\/p>\n<h2>C# and Razor Editing Experience<\/h2>\n<p>Once connected to a Codespace with your .NET Core project you\u2019ll see that the experience you are familiar with in writing C# remains familiar to your current local experience.\u00a0 Leveraging most of the <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/catch-up-on-the-latest-net-productivity-features\/\">latest .NET productivity features<\/a> and <a href=\"https:\/\/aka.ms\/refactorcode\">code refactoring<\/a> you\u2019ve come to know are available and now powered by the service for your project.\u00a0 It is our goal to ensure that the core developer experience with C# and .NET remain consistent when connecting to a Codespace.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-28071 size-large\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-roslyn-1024x201.png\" alt=\"Screenshot of code fixes in Visual Studio\" width=\"640\" height=\"126\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-roslyn-1024x201.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-roslyn-300x59.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-roslyn-768x151.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-roslyn.png 1501w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>We have done the work to add support for the various flavors of ASP.NET Core projects. You can do everything from Blazor development to ASP.NET Core MVC and Razor pages.<\/p>\n<p>You can currently use a preview version of Razor&#8217;s C#, HTML and Blazor\/TagHelper completion:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-28140\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/taghelpercompletion2.gif\" alt=\"TagHelper completion\" width=\"435\" height=\"241\" \/><\/p>\n<p>We have also added the ability to hover over C#, HTML and Blazor\/TagHelper pieces in order to have more context when navigating your Razor files:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-28073\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/razor-hover.gif\" alt=\"Animated image of hover properties in Razor pages\" width=\"689\" height=\"253\" \/><\/p>\n<p>Lastly, as developers it is nice to know about compiler errors in your Razor files whether it be from C#, HTML, or Razor itself. This is something we have added preview support for:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-28074\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/razor-compiler-errors.gif\" alt=\"Animated image of a Razor compiler error warning\" width=\"396\" height=\"149\" \/><\/p>\n<h2>Test Experience<\/h2>\n<p>Along with your coding experience, we all know that you write incredible unit tests for your code.\u00a0 You do, right?\u00a0 Visual Studio\u2019s test experience is pretty great, and this was one of the capabilities that we enabled early on for Codespaces.\u00a0 Enabling running your test suite using the cloud compute power we feel is a great value add for your inner loop experience.\u00a0 You can continue to use Test Explorer to see and execute your tests.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-28075 size-large\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-testexplorer-1024x463.png\" alt=\"Screenshot of Test Explorer\" width=\"640\" height=\"289\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-testexplorer-1024x463.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-testexplorer-300x136.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-testexplorer-768x347.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-testexplorer.png 1223w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>When they execute your Codespace will be the one taking the responsibility to run them so large iteration tests will be able to leverage more compute (assuming you\u2019ve chose a larger Codespace) and complete your tests quicker, then scale back if needed and continue development.\u00a0 In my own unit tests, I bumped up one loop and saw 15s savings on just one test alone as I scaled up to a larger Codespace larger than my dev workstation.\u00a0 We have more thoughts on testing in Codespaces to, so keep reading!<\/p>\n<h2>Building\/Debugging<\/h2>\n<p>Of course, as any developer using Visual Studio, your inner loop experience is critical.\u00a0 As you are developing your app your build and debug experience will also continue to be familiar in Codespaces. The difference is\u2026that is right, the compilation and debugging is happening on the cloud in your Codespace.\u00a0 Even so, your breakpoints, watch windows, immediate inspection of objects, etc. are there on your local workstation to interact with as you normally would.<\/p>\n<p>While working on console applications (or other client apps) you will get an experience where your app is remoted back to you as seen here:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-28076 size-large\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-appcastconsole-1024x451.png\" alt=\"Screenshot of console window in LiveShare\" width=\"640\" height=\"282\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-appcastconsole-1024x451.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-appcastconsole-300x132.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-appcastconsole-768x338.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-appcastconsole.png 1190w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>You will still be able to interact with it, but it will be running in the cloud!\u00a0 As we bring other client technologies online for Codespaces this will be the similar experience for those class of apps.<\/p>\n<p>You may be asking yourself then <em>If things are running in the cloud, how will my ASP.NET web app be browsable on localhost? Will I have to change my launch settings?<\/em> No you will not!\u00a0 We leverage the power of LiveShare technology to enable port forwarding of your localhost to the running app in the cloud.\u00a0 For your first launch of your ASP.NET app you\u2019ll see a few prompts in order to trust the developer certificate created on the Codespace to your machine:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-medium wp-image-28077\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert1-300x125.png\" alt=\"Trust certification dialog prompt\" width=\"300\" height=\"125\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert1-300x125.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert1.png 730w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/> <img decoding=\"async\" class=\"aligncenter wp-image-28078 size-medium\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert2-279x300.png\" alt=\"Trust Cert Dialog\" width=\"279\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert2-279x300.png 279w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/vscs-trustcert2.png 614w\" sizes=\"(max-width: 279px) 100vw, 279px\" \/><\/p>\n<p>Once you have accepted and trusted the developer cert, then when you launch your web app you\u2019ll interact normally with your local browser and still be able to debug normally.<\/p>\n<h2 id=\"future-tools\">Coming in the future<\/h2>\n<p>In addition to bringing more and more core functionality online, we are looking to continue leveraging the cloud compute to power some unique experiences. To give you a sneak peek we have been working on leveraging Codespaces to power the Live Unit Testing (we affectionately call LUT) experience using the cloud compute resources instead of local resources on your workstation:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-28082\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/lutincodespaces.gif\" alt=\"Animated image of Live Unit Testing\" width=\"1080\" height=\"640\" \/><\/p>\n<p>And one of the capabilities that Codespaces enables developers as well is the potential to target multiple OS targets for specific scenarios.\u00a0 Want to make sure your tests run Linux and Windows but not leave your dev environment?\u00a0 No problem, just change the running target!<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-28079 size-full\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/05\/testinlinux.gif\" alt=\"Animated image of changing a test target in Visual Studio\" width=\"1080\" height=\"712\" \/><\/p>\n<p>These experiences are just an example of what we are exploring as we leverage more cloud compute capabilities of Visual Studio Codespaces.<\/p>\n<h2>Expectations for .NET Core<\/h2>\n<p>Now that you are excited to use Codespaces with Visual Studio let me tell you where the support is in the current preview. For now, we recommend using Codespaces for .NET Core projects that are solely console, ASP.NET Core, or library apps. No designers are implemented so any apps with UI that relies on designers should wait for later versions. Think backend or middle-ware apps with few dependencies outside a public NuGet feed. Apps that are \u2018server-ready\u2019 that run in relative isolation will be the easiest to start with. For this first preview version, no Azure services can connect to the development environment of your app including KeyVault and AAD integration. Some of the features you know and love like CodeLens, ENC, code actions with sub menus, NuGet Package Manager, etc. will also not be available in this first preview. Hopefully, this helps paint the picture of isolated, server-side apps that are good candidates for development in the Visual Studio Codespaces preview.<\/p>\n<p>We are aware these constraints will affect some of you and we are continually working to enable as many of them as we can and will be updating the Codespaces service and Visual Studio as we implement the capabilities and more.<\/p>\n<h2>Summary<\/h2>\n<p>Did you see a theme here?\u00a0 A big advantage for Codespaces for a good set of developers will be leveraging the power of cloud compute without sacrificing your experience and productivity on your workstation.\u00a0 We would love for you to try out Codespaces with your .NET Core projects and give us feedback.\u00a0 If you are looking for a project to use outside of your own to explore as well, head on over and use the <a href=\"https:\/\/github.com\/dotnet-architecture\/eShopOnWeb\">eShopOnWeb<\/a> reference app as we\u2019ve been using that one ourselves during our validation of capabilities.<\/p>\n<p>I\u2019m sure you already signed up for the early access like I asked in the beginning of this post, but just in case, <a href=\"https:\/\/aka.ms\/vsfutures-signup\">here\u2019s the link again to sign up<\/a>!\u00a0 After you get access, you will be able to create Codespaces for your repos and use Visual Studio 2019 to continue your development on them using the power of cloud compute!\u00a0 As you have feedback please use the Feedback Tool in Visual Studio to report issues as this really helps us get the necessary diagnostics from the client and service to be able to better address the feedback.<\/p>\n<p>On behalf of the entire .NET team helping to deliver great developer tools, thanks for reading and we look forward to your feedback!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn about how we are enabling .NET Core projects for Codespaces when using Visual Studio 2019.<\/p>\n","protected":false},"author":1328,"featured_media":28370,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,196,197,646],"tags":[],"class_list":["post-28070","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-dotnet-core","category-aspnet","category-visual-studio"],"acf":[],"blog_post_summary":"<p>Learn about how we are enabling .NET Core projects for Codespaces when using Visual Studio 2019.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/28070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/1328"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=28070"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/28070\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/28370"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=28070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=28070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=28070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}