[00:00:06] Hello, I am Damian Edwards. I work on [00:00:08] the .NET team, and I am going to talk to [00:00:10] you today about file-based apps, [00:00:12] including a bunch of new stuff that [00:00:14] we've added in .NET 11. So, let me [00:00:18] There's no slides. We're just going to [00:00:19] like look at code today. I might refer [00:00:21] to my notes a couple of times, but we're [00:00:22] kind of trying to do a full overview of [00:00:24] file-based apps, including what we [00:00:26] initially shipped in .NET 10, uh some of [00:00:29] the improvements that we added during [00:00:30] the .NET 10, what we call the feature [00:00:32] band releases like 10 0300 and 10 0400, [00:00:36] and then some of the brand new stuff [00:00:37] that has now landed in 11 0 100. So, I'm [00:00:41] in a folder here, [00:00:42] and you can see I've got a hello.cs [00:00:45] uh file here. If I have a look inside [00:00:46] this file, you can see it's it's very [00:00:48] straightforward. It's just a couple of [00:00:51] lines of C Sharp. It's not uh [00:00:52] particularly interesting. It looks at [00:00:54] arguments and then prints out a string, [00:00:55] very classic kind of hello world. I can [00:00:58] go ahead and run that with .NET run [00:01:00] hello cs, [00:01:02] and we'll see that hey, there, my [00:01:03] application has run. Now, this is [00:01:05] probably what you've seen already if [00:01:07] you've ever done uh file-based apps, but [00:01:09] I really want to try today to try and [00:01:11] show you some things that perhaps you [00:01:12] didn't realize on first glance. So, [00:01:15] there's a few things about file-based [00:01:16] apps uh that if you scratch below the [00:01:19] surface, hopefully uh this information [00:01:21] will be useful to you. So, one of those [00:01:23] things is you don't have to say .NET [00:01:24] run. You can just say .NET hello cs, and [00:01:26] that also works. Um some other things [00:01:29] here, you'll note that this uh [00:01:30] application takes some arguments here. [00:01:32] So, I could pass in .NET hello and then [00:01:35] pass in the argument Damian. And so now [00:01:37] it says hello Damian because it's [00:01:38] reading uh those arguments from the [00:01:40] standard uh from the argument list [00:01:41] that's passed in. Uh but how can I do [00:01:43] that canonically? Well, if you want to [00:01:46] if you're invoking file-based apps from [00:01:48] a script or from some type of [00:01:49] environment where it's not just you as a [00:01:51] human or you need to be able to [00:01:53] disambiguate between what this command [00:01:56] looks like it should do and what it [00:01:57] might otherwise do if it 's not exactly [00:02:00] to .NET what to do here. You can get a [00:02:03] lot more explicit. So you can say .NET [00:02:05] run dash dash file hello.cs and that is [00:02:08] very explicitly saying I want you to run [00:02:10] this file, okay? Don't just look at the [00:02:12] first argument passed after run and then [00:02:15] try and figure out if that's a C# file [00:02:17] and then run it. No, I am telling you [00:02:18] this is a C# file. [00:02:20] Secondly, I can do dash dash here to [00:02:22] separate my invocation command from the [00:02:25] arguments that I'm going to pass to my [00:02:28] application rather than to the [00:02:30] invocation command itself. So if we just [00:02:32] quickly pass this whole line here, so [00:02:34] .NET is the command I'm running. We have [00:02:36] a sub command called run and then I'm [00:02:38] passing that a named argument called [00:02:41] dash dash file which is taking an [00:02:43] argument value and I can continue to [00:02:45] pass arguments here, you know, 1 2 3 and [00:02:48] they will be passed through to .NET run [00:02:50] and it may or may not choose to use [00:02:52] those arguments or pass them through to [00:02:54] my application. Again, if I want to be [00:02:56] explicit, I can say dash dash here and [00:02:58] now it says everything after here I want [00:03:00] you to pass to my application. So then [00:03:03] I'm going to go ahead and just use what [00:03:05] I'd done previously, .NET conf, and you [00:03:06] can see now that I got the exact same [00:03:08] output but everything was explicit. [00:03:11] Okay? So if you need to be explicit [00:03:12] here, this is kind of the full form full [00:03:14] fat version. The last thing I want to [00:03:16] show you is you can actually execute C# [00:03:19] code from standard in. So if I do [00:03:21] something like console Well, look at [00:03:22] that. I've already done it previously. [00:03:24] So I can do console.writeline hello from [00:03:26] standard in. I encapsulate that as a [00:03:28] shell string. In this case, I'm in [00:03:29] PowerShell and then I pipe that to .NET [00:03:32] run hyphen. The hyphen indicates that [00:03:35] hey, I want you to read the code for my [00:03:38] file based app from standard in and then [00:03:40] that will go ahead, compile that and [00:03:42] look at that. I've got hello from [00:03:43] standard in. So there are certain [00:03:45] circumstances where that might be useful [00:03:46] to you. I know that there are some tools [00:03:48] in the wider community that utilize this [00:03:51] facility to kind of create higher level [00:03:52] functionality like hey, I could execute [00:03:54] C# from a GitHub repo for example. [00:03:57] And so the way that that usually ends up [00:03:59] happening is either through standard in [00:04:00] or by saving to a temporary file and [00:04:02] running that. So, lots of different ways [00:04:04] to execute the same thing there. If I go [00:04:06] over and I look at that file in [00:04:09] uh VS Code over here, I've got VS Code [00:04:11] running with C# Dev Kit. And you'll note [00:04:13] that, you know, this gives me the [00:04:15] experience that I would expect as a C# [00:04:17] developer. I've got syntax highlighting. [00:04:19] If I hover over things, I can see that [00:04:21] I'm getting my statement or signature [00:04:22] help. If I was to try and overtype this, [00:04:25] I should expect that I can get control [00:04:27] space. Yes, I get IntelliSense here. [00:04:29] This is C Sharp. It's not a different [00:04:31] dialect. It's not C# scripting. It is [00:04:34] not C# interactive, which we had uh [00:04:37] previously had a uh sort of beta not [00:04:40] really well supported version of C# [00:04:43] called C# Interactive or CSX. This is [00:04:45] full fat C# It's just that the project [00:04:49] is virtual. There is no project file [00:04:51] here. It is basically being synthesized [00:04:53] on demand based on uh what you we see [00:04:57] here in this file. [00:04:59] Okay, some other things that are [00:05:00] interesting about uh this at the very [00:05:02] beginning are that you may have noticed [00:05:04] some of the timings over here. So, I've [00:05:05] got my shell set up to actually time [00:05:07] execution of things. And you may see [00:05:09] that sometimes when I run the same [00:05:11] thing, it runs a little faster than it [00:05:12] did before. So, I'm going to run it with [00:05:14] the same arguments and then I'm going to [00:05:15] run it again. And you can see the timing [00:05:17] kind of moves around a little bit. Now, [00:05:19] we've actually done a bunch of work in [00:05:20] file-based apps in the .NET SDK to [00:05:23] implement build caching. And so, I've [00:05:25] got a script here that I can run. So, [00:05:27] I'm going to go ahead and run this [00:05:28] measure launch PS1 script. And this is [00:05:29] going to take about 15 seconds. And then [00:05:32] this will allow us to see some different [00:05:33] timings for the different modes that [00:05:35] represent various cache states so that [00:05:37] you can build a mental model for what [00:05:39] we're skipping when we detect that [00:05:41] perhaps that step is not required and [00:05:44] how that uh impacts the overall [00:05:46] execution time. Okay, so we've done a [00:05:48] whole bunch of different executions of [00:05:49] just that hello.cs file there. And you [00:05:51] can see I 've got a bunch of different [00:05:52] timings here. But what's most [00:05:54] interesting to me is the table at the [00:05:55] bottom which gives me the median. So, [00:05:57] for an uncached build, you can actually [00:05:59] disable the cache by passing dash dash [00:06:01] no cache when you invoke .NET run, you [00:06:04] know, your file name. Um, that's, you [00:06:06] know, about a second on this machine, [00:06:07] when I run with no caching every single [00:06:09] time. That represents doing the [00:06:12] equivalent of a .NET build or a .NET run [00:06:15] on a traditional CS project, okay? The [00:06:18] fresh output mode here is not passing no [00:06:21] cache. Instead, what it's doing is it's [00:06:23] copying hello.cs to a different [00:06:25] directory every single time. And why [00:06:27] that's key is because it breaks our [00:06:30] build cache key. So we use the file path [00:06:33] of the entry point file. So in this [00:06:35] case, the path of where am I? I'm in [00:06:37] this path here, /hello.cs. [00:06:40] We'll take a hash of that, and then we [00:06:41] will use that as the cache key along [00:06:44] with a few other things, the version of [00:06:45] the SDK you're using, etc. Um, and then [00:06:48] we will use that to determine as to [00:06:49] whether we have to actually cache or [00:06:51] not. So when I create a new directory [00:06:53] every time and put hello.cs in it, which [00:06:55] I do for these runs here, I get a fresh [00:06:57] unused cache. But you'll note that it's [00:07:00] much quicker than this un cached build. [00:07:02] And why is that? Well, but that's that's [00:07:03] because this file is really simple. [00:07:06] There is just C# here. There is no uh [00:07:08] what we call directives, which I'll show [00:07:10] you in just a moment, which indicates to [00:07:12] us that we don't actually need to invoke [00:07:13] MSBuild. We actually completely skip [00:07:16] invoking MSBuild if it's just C# that we [00:07:19] have to execute, and we directly go to [00:07:21] the compile stage of what would [00:07:23] typically be a full build, and we just [00:07:25] run the compiler. So these times here [00:07:27] are indications that this application is [00:07:30] very basic. All we have to do is run it [00:07:32] through the C# compiler because it's [00:07:34] just C# and that's how long it takes to [00:07:36] do that plus execute it. [00:07:37] The next one is when I go ahead and I [00:07:39] make a change to this application, but I [00:07:41] change a directive. So I can add [00:07:43] directives at the top of this file. A [00:07:44] directive is just a hash colon line [00:07:47] followed by a keyword that we [00:07:48] understand. In this case, I'm going to [00:07:49] use property, and I'm going to say [00:07:51] something equals one. Okay? Now that is [00:07:53] a directive. It it shows this in this [00:07:55] case, it's setting a property uh on the [00:07:57] virtual project. Uh the property name is [00:07:59] something and it equals one. If we [00:08:00] detect that any of the the directives in [00:08:03] the application change from run to run, [00:08:05] then we know that we have to go back to [00:08:07] MSBuild, because these directives [00:08:08] directly map to changing the virtual [00:08:11] project, which means that that project [00:08:12] needs to be built. So, that's what this [00:08:14] run here says. Every single time we do a [00:08:16] run here, we're changing a directive by [00:08:18] just tweaking a value, and that [00:08:20] indicates that we had to go through the [00:08:21] full MSBuild pipeline. And you can see [00:08:23] that here for this particular app on [00:08:25] this machine, that's taking about a [00:08:26] second for every execution. So, you can [00:08:28] probably see why we started to do some [00:08:30] of this build caching here to avoid [00:08:32] having to do that full build every time [00:08:35] you run your file-based application. The [00:08:37] next one after that is showing that we [00:08:39] just changed source. So, let's assume [00:08:41] that now we've got a simple application [00:08:43] again, or we have directives, but we've [00:08:44] detected that they haven't changed. And [00:08:46] all I do is I come in and I change this [00:08:49] here to say one file change. We can [00:08:51] detect that the only thing that changed [00:08:52] from the last run was something in the C [00:08:55] in the C sharp file that wasn't a [00:08:57] directive. So, this is just code [00:08:59] changing. That's what these runs here [00:09:02] implement. So, if we just change the [00:09:03] source, it becomes very similar to this [00:09:05] second line where we just have to run it [00:09:07] through the compiler. We don't have to [00:09:08] do a full build. We can take the output [00:09:10] of the rest of the build and then just [00:09:12] do that recompilation phase. And that's [00:09:15] why you can see that those execution [00:09:16] times were so much faster. And then [00:09:18] lastly, we do five runs without changing [00:09:20] anything at all. So, if nothing changes [00:09:22] from run to run, then we don't have to [00:09:23] do anything. We just have to go and find [00:09:25] the assembly that was produced in the [00:09:27] last execution, and then we just run [00:09:29] that directly. And you can see there [00:09:30] that that gets us right down to like 100 [00:09:32] millisecond execution times for the same [00:09:35] application, which is really really cool [00:09:36] to see. [00:09:37] Okay. [00:09:39] Let's move on to something else. [00:09:42] Let's go and look at something that [00:09:42] might be slightly more useful. So, [00:09:44] instead of hello, I'm going to go to my [00:09:45] second one here and we'll open this [00:09:47] plan.cs. So, now we're going to see some [00:09:49] things that are a little bit newer [00:09:52] thanks to the work that's happened since [00:09:53] we released .NET 10. I've got a few more [00:09:56] directives up here. The big one here is [00:09:58] this include directive. Now, I can now [00:10:00] include other C sharp files in my [00:10:02] file-based application. So, in this [00:10:05] case, I'm including a file called [00:10:06] session plan. You can see that it 's [00:10:07] right next to it, so I can open that up. [00:10:09] It's just defining some classes that [00:10:11] have some members on it. But very [00:10:12] importantly, this file also includes [00:10:15] other files. So that means we support [00:10:17] transitive directive processing. So I [00:10:19] can include session plan. Session plan [00:10:21] itself says it includes this other file [00:10:23] from the helpers folder, so I can go and [00:10:25] open that up. [00:10:26] And then you can see this file has a [00:10:27] directive that actually declares it [00:10:29] needs a package reference. So I can [00:10:31] actually keep the package references [00:10:33] on the files that require them, rather [00:10:36] than them being in the root file where [00:10:38] there may be no code in this actual uh [00:10:40] file here that I'm looking at that needs [00:10:42] that package. It actually is the file [00:10:45] that gets included transitively that [00:10:46] requires this file. So that's a new [00:10:48] feature uh in .NET 11. You can use this [00:10:51] uh right now, which is kind of nice. [00:10:53] Okay. If we look at this package [00:10:55] directive here, it's pretty I I think [00:10:57] it's pretty self-explanatory. You have [00:10:58] got the uh identity of the NuGet package [00:11:01] here that we're trying to uh declare [00:11:03] that we need, and then we separate that [00:11:05] with the at symbol and then the version [00:11:07] that we want to get. We can also use [00:11:09] like any valid NuGet version here, so I [00:11:11] can put a star here to say, hey, just [00:11:12] get me the latest version. That's the [00:11:14] float syntax. You could also do [00:11:15] partials, so I could do uh 214.star and [00:11:19] that will float to the latest patch. You [00:11:20] can also if you're using something like [00:11:22] central package management, you can [00:11:23] completely omit the package version, and [00:11:25] then that will delegate like normal for [00:11:27] a traditional project to the [00:11:29] directory.packages.props [00:11:31] file uh to determine what the version of [00:11:33] the package should be. [00:11:36] Okay. [00:11:38] The other thing I want to make sure [00:11:39] that's understood here is that we've got [00:11:40] some great tooling in uh C# Dev Kit for [00:11:43] some of these new features. So if I just [00:11:44] delete that and I hit control space, you [00:11:46] see that uh C# Dev Kit knows that this [00:11:49] is expected to be a file in here. Um and [00:11:51] so I can actually go ahead and start [00:11:53] typing and I get completion for file [00:11:54] paths in here, which is really really [00:11:56] nice as well. [00:11:57] Now you can do globs in here. They don't [00:11:59] have to be specific uh files. So I could [00:12:02] come over to session plan here and say, [00:12:03] hey, I want to just grab everything [00:12:05] inside helpers star.cs, just like you [00:12:08] could do in a in a traditional project. [00:12:10] You could have an include um or a [00:12:12] compile item, I should say, in your item [00:12:14] group, and then you could say, hey, [00:12:15] include some path star dot something [00:12:17] else. The only thing that you have to be [00:12:19] careful of when doing that is that [00:12:21] invalidates our build cache. We can no [00:12:22] longer do the cache checking. We don't [00:12:25] at the moment support expanding that [00:12:27] glob before we pass it to MSBuild uh to [00:12:30] determine if any of those files that [00:12:31] have matched have either now matched a [00:12:33] different set of files or any of the [00:12:35] files have changed since the last time. [00:12:36] So you can absolutely use wildcard [00:12:38] globbing in here, but do note that it [00:12:40] will disable the build caching that I [00:12:41] showed you just before. [00:12:43] Okay. [00:12:44] The last thing I want to show here [00:12:45] that's new in .NET 11 is this extra bit [00:12:48] of content just here. So in the initial [00:12:50] version of file-based apps, well, up [00:12:52] until 11, we didn't support metadata on [00:12:55] directives. So this package declaration [00:12:57] now, I can say, hey, [00:12:59] I want this to be private assets all, [00:13:01] which set tells NuGet that yes, I need [00:13:03] to depend on this package, but I don't [00:13:04] want to pass this package reference onto [00:13:07] anyone who depends on me. Okay? Now [00:13:09] again, this is something that's [00:13:10] obviously being supported in uh regular [00:13:13] projects. Uh and we now support this [00:13:15] metadata inclusion on uh suitable [00:13:18] directives in file-based apps as well. [00:13:20] And this is really important for certain [00:13:21] types of packages which actually expect [00:13:24] you to use them this way. They really [00:13:25] aren't designed to flow transitively. [00:13:27] And so today, if you would try to use [00:13:29] one of those packages from a file-based [00:13:30] application, you can run into issues [00:13:32] because of your inability to express [00:13:34] this intent via metadata. We call these, [00:13:37] you know, key name and and value [00:13:39] keywords on the side here, metadata. Um [00:13:42] and now you can. In .NET 11 is now [00:13:44] available uh for you to do so. So that's [00:13:45] also a nice improvement. [00:13:49] All right, let's go and look at reusing [00:13:52] this uh somehow. So I have shown you so [00:13:55] perhaps a a slightly better uh or more [00:13:57] or more useful tool that was a little [00:13:59] more complicated and uses some more [00:14:00] features. Let's go ahead and build a [00:14:02] different application that reuses some [00:14:05] of those um uh [00:14:08] functionalities from my first [00:14:09] application. So this one is actually a [00:14:10] web application. You can absolutely [00:14:11] build web applications using file-based [00:14:14] apps. If I come over to my terminal and [00:14:17] I look inside the folder that we are [00:14:18] here, I can .NET [00:14:20] web.cs and that's going to go ahead and [00:14:22] run my web application directly from [00:14:25] that single file. [00:14:27] Um and here it is. It's running right [00:14:28] here. I can control click on here and we [00:14:30] can see I'm getting a result. [00:14:33] Some other things that you might notice [00:14:34] looking at the files here, I've got [00:14:36] these two other files here. So [00:14:37] web.run.json and web.settings.json. [00:14:41] So just like if you are used to building [00:14:43] ASP.NET Core applications or you have [00:14:45] used the microsoft.extensions.hosting [00:14:48] namespace of APIs that include the [00:14:50] generic host, the worker project host, [00:14:53] or of course the web host is built on [00:14:55] that as well. They support these ideas [00:14:57] of a hosted application with dependency [00:14:59] injection, configuration, setting [00:15:01] support, etc etc. And you can now very [00:15:04] easily um just include a web.settings [00:15:06] file here. It's just named after your [00:15:07] application. So if my application was [00:15:09] called foo.cs, this would be called [00:15:11] foo.settings.json. [00:15:13] In my case it's called web.cs, so I call [00:15:14] it web.settings.json. [00:15:16] That will be implicitly read by the web [00:15:18] host and those settings will be applied. [00:15:21] The run file here, I'm going to go to [00:15:23] Visual Studio and [00:15:24] VS Code and show you these. So this is [00:15:26] your launch settings, okay? So my [00:15:27] web.run [00:15:29] .js .json file here is just my launch [00:15:32] settings file with a different naming [00:15:33] scheme to make it better match [00:15:36] file-based apps. So in traditional [00:15:38] projects, this would be in your [00:15:39] properties folder inside the project and [00:15:42] it would be called launch settings.json. [00:15:44] In a file-based application, we have the [00:15:46] file next to the actual application file [00:15:49] and we just name it based on the name of [00:15:51] the application file. So I've actually [00:15:53] enabled um file nesting in the Explorer [00:15:56] in VS Code over here. This is an [00:15:58] optional feature that you can turn on in [00:16:00] VS Code and then you can define patterns [00:16:03] for what files will get nested under [00:16:05] other files. So I've turned that on and [00:16:06] I've tweaked my patterns a bit. And so [00:16:08] you can see here that the web.run.json [00:16:10] is being nested under web.cs and as is [00:16:13] web.settings.json [00:16:15] because uh we recognize that those are [00:16:18] to my web.cs file based app. And so the [00:16:21] settings file is uh probably as you [00:16:22] expect if you're used to seeing uh the [00:16:24] appsettings. json file in a traditional [00:16:26] project or an ASP.NET Core application, [00:16:28] this is the exact same content, but [00:16:29] again we've just renamed the file here [00:16:31] to better match the layout of a file [00:16:33] based app. [00:16:34] So what does this actual file based app [00:16:36] look like? Well, as I said, this is a [00:16:38] web application, so there's a few [00:16:39] changes here. We've got a few more [00:16:41] directives. Uh the first one up here is [00:16:43] what we call a shebang, and I'm going to [00:16:44] talk a little bit more about that just [00:16:46] in a minute. The second one is an SDK. [00:16:48] So an SDK is a really powerful [00:16:49] directive. Uh this allows you to [00:16:51] reference an MSBuild SDK. Now in this [00:16:55] case, we're referencing one that comes [00:16:57] with the base .NET SDK, so I don't have [00:16:59] to put a version or anything on here. I [00:17:01] can simply say, hey, microsoft.net [00:17:03] sdk.web and this will be the MSBuild SDK [00:17:06] that's used to as part of this [00:17:08] application. You can also do NuGet based [00:17:12] uh SDK. So if I come over here and I [00:17:14] look at cake.cs, you may have heard of [00:17:16] the project called cake. It's a open [00:17:19] source project in the ecosystem for [00:17:20] building build scripts using C#. Um so [00:17:23] you can kind of think of it like make, [00:17:24] but you use C#, hence cake. [00:17:27] Uh and so they have an SDK that is [00:17:29] targeted for folks using file based [00:17:31] apps. So here is a single file C# based [00:17:35] build script that uses the cake SDK uh [00:17:38] in order to bring in all the cake based [00:17:40] types, all the cake build settings that [00:17:42] are required. This is under the covers [00:17:44] referencing packages, what we call [00:17:46] implicit references that you don't have [00:17:47] to see, which is how it is I I'm getting [00:17:49] all these APIs in here. They're actually [00:17:51] being brought in as part of the restore [00:17:53] just because I'm using this hash colon [00:17:55] SDK uh line up here. So that's really [00:17:58] cool as well. [00:18:00] Here is a new directive in .NET 11. This [00:18:03] is an app to app reference directive. So [00:18:06] SDK lets me reference an SDK, uh [00:18:09] hash colon package lets me reference a [00:18:11] NuGet package, hash colon ref lets me [00:18:14] reference another file based app. So in [00:18:16] this case, I wanted to go and reference [00:18:18] the app I showed you in the previous [00:18:20] step. That was my plan.cs. It is an [00:18:22] application. I can run it from the [00:18:24] command line, but just like today with [00:18:25] regular projects, you can have a console [00:18:27] application project and then reference [00:18:29] that from another project and all the [00:18:31] public APIs in that console application [00:18:33] project will be available to call from [00:18:35] the project that references it. This is [00:18:37] the exact same idea. So I can just do a [00:18:40] ref, point it to the CS file, and now [00:18:42] that will get imported into the virtual [00:18:44] project, and everything inside plan.cs [00:18:46] will be brought in and available to me [00:18:48] in my web.cs project as well. [00:18:50] Lastly, you can reference traditional [00:18:52] projects as well. And so in this case, [00:18:55] my uh [00:18:56] repo here has a projects folder. Inside [00:18:59] of that is a traditional CS proj, and it [00:19:02] has a brand.cs [00:19:05] class as part of that CS proj. This is [00:19:07] just building a class library. I can [00:19:08] reference that. No problem at all. I can [00:19:10] just bring that in using hash colon [00:19:12] project, point to the path for the CS [00:19:14] proj, and then that will get brought [00:19:16] into the virtual project that represents [00:19:18] web.cs. [00:19:19] So you can see a lot of things coming [00:19:20] together here now to allow me to build [00:19:22] file-based apps that are a lot more than [00:19:24] just a single file. I can now express [00:19:26] and organize my files in any way that I [00:19:29] really choose, and then I can reference [00:19:31] them across different folders. I can [00:19:32] create isolated spaces for them, um or I [00:19:35] can even reference kind of the [00:19:36] traditional world by referencing full CS [00:19:38] projects. And then if I want to get [00:19:39] really complicated or or feature rich, I [00:19:42] should say, I can build my own SDKs like [00:19:45] we have for cake well like we saw for [00:19:47] cake here, and then you can distribute [00:19:48] those on NuGet for other people to [00:19:50] consume, or you can just distribute [00:19:52] those uh for yourself to consume as [00:19:53] well, [00:19:54] which I think is pretty cool. [00:19:56] Okay. [00:19:57] Let's have a look at some more stuff [00:19:58] that's supported in the tool chain. So [00:20:01] in .NET 11, we did a lot of work in the [00:20:03] .NET SDK to go through all of the [00:20:05] commands and update them all to [00:20:07] understand file-based apps. When we [00:20:08] first launched uh file-based apps in [00:20:10] .NET 10, that wasn't the case. It was [00:20:12] really only .NET build, .NET restore, [00:20:14] .NET run, and .NET publish that really [00:20:15] understood how to how to to work with a [00:20:17] file-based app. But now pretty much [00:20:19] everything understands how uh uh with [00:20:21] file-based apps. So I'm going to go back [00:20:23] uh to this folder here. I'm going to go [00:20:25] up. [00:20:26] I'm going to go up one and we're going [00:20:27] to go into my uh zero fall here. [00:20:30] All right. And so now I can do things [00:20:32] like uh .NET format. [00:20:34] So I can do .NET format format me. So at [00:20:36] the moment you can see that like I've [00:20:37] got no whitespace here. So if I go ahead [00:20:39] and run that now, [00:20:40] the .NET format command, if you're not [00:20:42] familiar with it, it's part of the SDK [00:20:43] and it will go ahead and actually update [00:20:46] um the CS files or projects uh to a here [00:20:49] to whatever your formatting rules are. [00:20:50] So in this case uh I don't really have [00:20:52] any complicated custom formatting rules [00:20:54] in this workspace and so it's just [00:20:55] applied the defaults, which in this case [00:20:57] is just hey, let's go ahead and add [00:20:58] whitespace everywhere. Awesome. Very [00:21:00] very good to see. Here I have a package [00:21:02] that I know is out of date. So how could [00:21:04] I go ahead and use the commanding system [00:21:06] in the SDK or in the wider .NET [00:21:08] community to to to look at this. So [00:21:11] let's go and have a look at that. [00:21:12] So I've got that package packages thing [00:21:14] here. I can do .NET uh package list and [00:21:17] then I'm going to say uh that .file and [00:21:20] we'll do packages.cs. And so this is the [00:21:22] standard command that you can use to [00:21:24] look at all the file all the packages [00:21:26] that are being listed uh or used sorry [00:21:28] by a project. And in this case it's now [00:21:30] working with file-based steps. You can [00:21:31] see these are the automatic or implicit [00:21:33] project references that are coming [00:21:35] through from the SDK and then here's [00:21:37] that humanizer core one that's come [00:21:39] through. Now I can uh change this too to [00:21:41] ones that are outdated. So if you want [00:21:42] to see do I have any outdated package [00:21:44] references, I can just pass dash dash [00:21:46] outdated and sure enough I can now see [00:21:48] that yes, humanizer core I've been [00:21:50] referencing an old version and I could [00:21:51] go ahead and update that to a newer one [00:21:53] version. And if you weren't aware, you [00:21:55] can also do uh vulnerable versions uh if [00:21:58] I get the uh [00:22:00] get the flag right vulnerable. I just [00:22:02] didn't spell it right. Vulnerable. [00:22:05] Vulnerable. [00:22:07] Uh so this is how you would go ahead and [00:22:08] list vulnerable packages. You might also [00:22:11] be familiar with a community tool called [00:22:12] .NET outdated. And so .NET outdated [00:22:15] allows us to do something like [00:22:17] uh quite similar. I updated .NET [00:22:18] outdated to support file-based steps a [00:22:20] little while ago. So I can now do .NET [00:22:22] outdated uh packages.cs. I can pass it [00:22:25] directly in and that will give me the [00:22:27] .NET outdated experience but on [00:22:29] file-based apps. And if I'm really keen, [00:22:31] you can even go right out to the root, [00:22:33] and you can do .NET outdated. You can [00:22:35] say I want to enable FBAs, file-based [00:22:39] and I want to do recursion. And then [00:22:40] that will do the entire workspace [00:22:42] recursively for all projects and [00:22:44] file-based apps and then give me a [00:22:46] report of everything that is out of [00:22:48] date. And if I was to pass -u, it would [00:22:50] go ahead and also update those. You [00:22:52] know, very very powerful command if you [00:22:54] haven't heard of that one already. All [00:22:55] right. So, lastly, let's jump over to [00:23:00] something that is specific to Unix. So, [00:23:02] I mentioned the shebang before. So, I'm [00:23:05] going to be running Ubuntu through the [00:23:08] Windows Subsystem for Linux or WSL here. [00:23:10] That's what this terminal over here is [00:23:12] showing. And in this case, I've got a [00:23:14] very similar file to what we've been [00:23:15] showing before, and it has this shebang. [00:23:17] So, what is a shebang? So, a shebang is [00:23:20] a shell instruction [00:23:22] that is supported on Unix or Unix-like [00:23:25] systems. So, it's supported on Mac and [00:23:27] it's supported on Linux or if you're [00:23:29] running [00:23:30] Bash on Windows or some other type of [00:23:32] Linux-like shell on Windows. [00:23:34] And it basically says, hey, if this file [00:23:36] is marked as executable, you can just [00:23:38] directly execute it. And this is what [00:23:40] will be used the shell uses to figure [00:23:42] out what to execute it with. So, in this [00:23:44] case, it's going to use the env command, [00:23:46] which is typical on Linux distributions [00:23:48] under the usr/bin folder. This argument [00:23:52] says please separate all the arguments [00:23:53] when you pass it in. And then I'm going [00:23:55] to tell it to run .NET. And so env [00:23:57] basically says run .NET as it is on my [00:23:59] path. Whatever .NET is on my path, I [00:24:01] want you to run that. And then I want [00:24:03] you to do the dash dash like we saw [00:24:05] before so that anything I pass [00:24:07] to the invocation of this will be get [00:24:09] passed through to my application. So, if [00:24:11] I'm in here and I go into Linux, I can [00:24:13] do lx-l and you can see that this is not [00:24:15] currently executable. So, I can change [00:24:17] that. I can do let's make this [00:24:18] executable by calling chmod and we'll do [00:24:21] +x. And then I'll look at the now I've [00:24:23] got that execute bit. So, now I can [00:24:25] actually just directly execute this. I [00:24:26] can say session.cs. Go ahead and it just [00:24:28] runs. I didn't have to say .net. I just [00:24:31] can go ahead and directly run that [00:24:32] application without having to do [00:24:34] anything. But we also support going one [00:24:36] step further. If I look inside my .home [00:24:39] directory, I think it's in uh not my [00:24:41] .home directory, my .local under home [00:24:43] and then I go to shared and I do to .net [00:24:45] conf, you'll see that I've got this uh [00:24:47] session.cs has already been copied there [00:24:49] previously, but there's also this just [00:24:52] session file. So what's that? Well, if I [00:24:54] do a dash L, you'll see that the session [00:24:56] file, the extensionless file is a [00:24:59] symlink to session.cs inside of here and [00:25:02] they're both marked executable. And this [00:25:05] uh so I can put this uh path [00:25:07] I can put this folder on my path now and [00:25:09] then this session command would be [00:25:11] available anywhere in my shell and it [00:25:13] would symlink and execute directly that [00:25:15] session.cs file. So if I go ahead and I [00:25:19] I have a command here to kind of uh [00:25:20] update my path just to finally [00:25:23] finish this out. I'm going to go and [00:25:25] grab this from my docs. I've got my demo [00:25:27] commands and I'm going to do .local in [00:25:29] here and I'm going to grab this one over [00:25:31] here. So I'm just going to add this to [00:25:32] my path. You can imagine this will be [00:25:33] part of your profile script or whatever [00:25:35] it might be uh in uh on your system. [00:25:38] And now I'm not in that folder, right? [00:25:40] I'm I'm back in my repo. I could go [00:25:42] outside of this. I could be in this. The [00:25:44] the session is just not there and I can [00:25:46] just type session now. Oh, and that [00:25:48] didn't work because I didn't do it [00:25:49] correctly. Let's do that again. [00:25:53] So we should have that on our path now. [00:25:55] Okay, that one's not going to that that [00:25:56] one's not going to work today, but [00:25:57] that's not a problem. So the key point [00:25:59] to take away from this is that we did do [00:26:01] the work to support uh extensionless uh [00:26:04] files. So specifically on Linux, if you [00:26:07] have a file [00:26:09] and it has a shebang at the front of it, [00:26:11] you can invoke it directly even if it [00:26:14] doesn't end in .cs. So as long as you [00:26:16] call .net and then file name, if it does [00:26:18] not have an extension, but it does have [00:26:21] a shebang, we will look inside of it, [00:26:23] verify it has the shebang, and we will [00:26:24] allow you to execute it as if it was a [00:26:26] session dot uh as if it was a CS file, [00:26:29] which is kind of cool. [00:26:30] Okay, so that was file based apps, a [00:26:32] little bit of an overview and obviously [00:26:34] the new stuff that we've done in .NET [00:26:36] 11. You've seen some new tooling that [00:26:38] we've added in C# Dev Kit. We are trying [00:26:40] to improve both of those things as we [00:26:42] ship updates. So C# Dev Kit basically [00:26:45] ships every month and we continue to [00:26:46] refine the experience there. The file [00:26:48] based apps experience, we actually do [00:26:50] update in the .NET SDK [00:26:52] feature band releases. So look for [00:26:54] 11.0.200 [00:26:56] to come out early next year and we may [00:26:58] be polishing this experience even [00:26:59] further and reacting to your feedback. [00:27:01] So try file based apps, give us your [00:27:03] feedback and yeah, thanks for watching.