Jump to content
Xtreme .Net Talk

  • Posts

    • Solution files have been a part of the .NET and Visual Studio experience for many years now, and they’ve had the same custom format the whole time. Recently, the Visual Studio solution team has begun previewing a new, XML-based solution file format called SLNX. Starting in .NET SDK 9.0.200, the dotnet CLI supports building and interacting with these files in the same way as it does with existing solution files. In the rest of this post we’ll show how users can migrate to the new format, explore the new support across the dotnet CLI, and discuss the next steps towards a generally-available release of the format. Getting started Before the 9.0.200 SDK, the only way to create a SLNX file was through the Visual Studio settings. The Environment > Preview Features > Use Solution File Persistence Model setting, when checked, would allow users to Save As their existing .sln files in the new .slnx format. The 9.0.200 SDK provides a command to do this same migration: dotnet sln migrate. Let’s start with a very simple solution and project setup to look at what it takes to migrate. First, we’ll create a new solution: PS C:\Users\chethusk\Code\example> dotnet new sln The template "Solution File" was created successfully. PS C:\Users\chethusk\Code\example> cat .\example.sln Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal Now, we’ll create a project and add it to the solution: PS C:\Users\chethusk\Code\example> dotnet new console -n my-app The template "Console App" was created successfully. Processing post-creation actions... Restoring C:\Users\chethusk\Code\example\my-app\my-app.csproj: Restore succeeded. PS C:\Users\chethusk\Code\example> dotnet sln add .\my-app\ Project `my-app\my-app.csproj` added to the solution. PS C:\Users\chethusk\Code\example> cat .\example.sln Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my-app", "my-app\my-app.csproj", "{845B7716-6F03-4D02-8E86-79F95485B5D7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|x64.ActiveCfg = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|x64.Build.0 = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|x86.ActiveCfg = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Debug|x86.Build.0 = Debug|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|Any CPU.ActiveCfg = Release|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|Any CPU.Build.0 = Release|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|x64.ActiveCfg = Release|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|x64.Build.0 = Release|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|x86.ActiveCfg = Release|Any CPU {845B7716-6F03-4D02-8E86-79F95485B5D7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal Now, let’s convert our solution to the new format: PS C:\Users\chethusk\Code\example> dotnet sln migrate .slnx file C:\Users\chethusk\Code\example\example.slnx generated. PS C:\Users\chethusk\Code\example> cat .\example.slnx <Solution> <Configurations> <Platform Name="Any CPU" /> <Platform Name="x64" /> <Platform Name="x86" /> </Configurations> <Project Path="my-app/my-app.csproj" /> </Solution> The new format is XML-based and is much more concise than the old format – but it contains all of the same data! The data that is missing from the new format is part of the defaults of the format, so no functionality is lost. This migration is made possible because the Visual Studio Solution team has created a new open-source library for parsing and working with both classic and XML-based solution files – the library is called Microsoft.VisualStudio.SolutionPersistence. Managing projects from the CLI You can do more than migrating solution files using the CLI, too. As you might expect, you can build the new solutions the same way you would build the old: PS C:\Users\chethusk\Code\example> dotnet build .\example.slnx Restore complete (0.6s) my-app succeeded (4.3s) → my-app\bin\Debug\net9.0\my-app.dll Build succeeded in 5.3s Note We specified the .slnx file explicitly above because it’s an error to run dotnet build or other commands that need to build in a directory with both a .sln and a .slnx – we don’t know which one to build! All of the other interactions you expect from the dotnet CLI work as well. We can add projects: PS C:\Users\chethusk\Code\example> dotnet new classlib -n my-lib The template "Class Library" was created successfully. Processing post-creation actions... Restoring C:\Users\chethusk\Code\example\my-lib\my-lib.csproj: Restore succeeded. PS C:\Users\chethusk\Code\example> dotnet sln .\example.slnx add my-lib Project `my-lib\my-lib.csproj` added to the solution. PS C:\Users\chethusk\Code\example> cat .\example.slnx <Solution> <Configurations> <Platform Name="Any CPU" /> <Platform Name="x64" /> <Platform Name="x86" /> </Configurations> <Project Path="my-app/my-app.csproj" /> <Project Path="my-lib/my-lib.csproj" /> </Solution> We can list the projects in a solution: PS C:\Users\chethusk\Code\example> dotnet sln .\example.slnx list Project(s) ---------- my-app\my-app.csproj my-lib\my-lib.csproj And finally we can remove projects from the solution: PS C:\Users\chethusk\Code\example> dotnet sln .\example.slnx remove .\my-lib\ Project `my-lib\my-lib.csproj` removed from the solution. PS C:\Users\chethusk\Code\example> cat .\example.slnx <Solution> <Configurations> <Platform Name="Any CPU" /> <Platform Name="x64" /> <Platform Name="x86" /> </Configurations> <Project Path="my-app/my-app.csproj" /> </Solution> Tip There are two commands that don’t work in 9.0.200, though – dotnet nuget why and dotnet list package – those will begin working in the 9.0.201 release in March. Support for SLNX across .NET IDEs and Tooling As mentioned above, the dotnet CLI has broad support for the new SLNX file format, but there are still many tools in the ecosystem that have partial or no support for the format. You will need to take this varying level of support into account when choosing whether to migrate to SLNX files. Some examples of tools that have varying levels of support for slnx today are: Visual Studio While the IDE will read the SLNX file when loaded, it currently will not load SLNX files unless the setting to enable SLNX persistence has been enabled. This means if you work on a team and users have not toggled this setting, they will not be able to open SLNX files at all. In addition, double-clicking on SLNX files doesn’t currently open Visual Studio instances the way that sln files do. C# Dev Kit C# DevKit can support SLNX files, but in order to do so you must set the dotnet.defaultSolution property to the path to your slnx file: { "dotnet.defaultSolution": "example.slnx" } slngen The slngen tool is a command-line utility used to synthesize a solution file for a given project to help make repos that prefer not to use solution files interoperate better with Visual Studio. This tool is not yet updated to support SLNX – the status of this support can be tracked at microsoft/slngen#643. JetBrains Rider Rider has preliminary support for the SLNX format, and details about their support can be tracked at RIDER-110777. Feedback and the road to GA Despite this end-to-end support in Visual Studio and the dotnet CLI, the SLNX format itself is still in preview. While we think it’s a great step forward in usability for many .NET developers, we want to hear from you as you try it in your teams. Try the migration paths in Visual Studio and the dotnet CLI, make sure things work as you expect in your CI/CD pipelines and local builds, and make sure to let the teams know about your experiences in the following ways: for CLI experiences, report new issues or discussions at the dotnet/sdk repository for Visual Studio experiences, please raise new tickets at the Visual Studio Developer Community for feature requests for the solution parsing library, report new issues at the microsoft/vs-solutionpersistence repository As we’re able to respond to your feedback and solidify core user experiences, we move closer towards being able to make this the default for Visual Studio and the dotnet CLI. Summary SLNX files are an exciting new change to the solution file format that we think will make it easier for teams to collaborate and understand their projects. The new capabilities in the dotnet CLI allow developers to have a full inner-loop and CI experience using the new format, so we’d love for .NET developers to read through the updated documentation, try the new support, and give us feedback! The post Introducing support for SLNX, a new, simpler solution file format in the .NET CLI appeared first on .NET Blog. View the full article
    • HybridCache is a new .NET 9 library available via the Microsoft.Extensions.Caching.Hybrid package and is now generally available! HybridCache, named for its ability to leverage both in-memory and distributed caches like Redis, ensures that data storage and retrieval is optimized for performance and security, regardless of the scale or complexity of your application. Why use HybridCache? HybridCache reliably simplifies the boilerplate code like object serialization, cache-aside pattern implementation, and data consistency down to a single line of code. It also optimizes the data performance by combining in-memory and distributed cache stores enabling the application to run faster. If you’re building ASP.NET Core applications that use repeated or complicated data queries, have a microservice-based architecture, or require real-time data processing, you should use HybridCache to improve the performance and responsiveness of your applications. Key features Built on top of IDistributedCache which means it is compatible with all existing cache backends such as Redis, SQL Server, CosmosDB, Garnet, etc. Simple and easy-to-use API Cache-stampede protection Cache invalidation with tags Performance enhancements such as inbuilt support for the newer IBufferDistributedCache API Fully configurable serialization for JSON and Protobuf Secure-by-default with authentication and data handling Keep reading to learn more about the key features! Simple API – GetOrCreateAsync If you’ve previously tried caching in your ASP.NET Core applications, you may be familiar with other abstractions such as IDistributedCache or IMemoryCache. With these you’d have to write the code to generate keys, try to retrieve the data matching the key from the cache, deserialize the data if it does exist in the cache, or serialize the data and push it into the cache if it did not exist. This is a very manual process and hooking up all the different components is time consuming, requires the knowledge of multiple APIs, and is difficult to get right. // This is the code without HybridCache public class SomeService(IDistributedCache cache) { public async Task<SomeInformation> GetSomeInformationAsync (string name, int id, CancellationToken token = default) { var key = $"someinfo:{name}:{id}"; // Unique key for this combination. var bytes = await cache.GetAsync(key, token); // Try to get from cache. SomeInformation info; if (bytes is null) { // Cache miss; get the data from the real source. info = await SomeExpensiveOperationAsync(name, id, token); // Serialize and cache it. bytes = SomeSerializer.Serialize(info); await cache.SetAsync(key, bytes, token); } else { // Cache hit; deserialize it. info = SomeSerializer.Deserialize<SomeInformation>(bytes); } return info; } // This is the work we're trying to cache. private async Task<SomeInformation> SomeExpensiveOperationAsync(string name, int id, CancellationToken token = default) { /* ... */ } } HybridCache simplifies the cache-aside pattern down to one single line of code while significantly accelerating your application data performance. // Same code as above, now using HybridCache public class SomeService(HybridCache cache) { public async Task<SomeInformation> GetSomeInformationAsync (string name, int id, CancellationToken token = default) { return await cache.GetOrCreateAsync( $"someinfo:{name}:{id}", // Unique key for this entry. async cancel => await SomeExpensiveOperationAsync(name, id, cancel), token: token ); } } Cache-stampede protection A cache stampede occurs when multiple clients request the same data simultaneously after it expires from the cache, leading to a surge of redundant computations and database queries. This can significantly slow down a web application and degrade the user experience, especially under high traffic conditions. HybridCache prevents cache stampedes by ensuring that when multiple requests for the same data arrive, it only performs the necessary computations once. Instead of allowing every request to independently regenerate the data, HybridCache detects the situation, processes the request a single time, and returns the result to all queued requests. This approach maintains data consistency and optimizes performance at scale. Cache invalidation with tags When you add an item to a cache, you can assign one or more tags to it, which are simply string values that help categorize this data. HybridCache now makes it easier to manage and invalidate data in bulk via tagging. For example, when needing to invalidate many items at a time from a cache, instead of deleting the keys one-by-one, you can delete all items with a specific tag with one API call. You can even delete items with multiple tags at a time simply by passing a set of tags. It’s no longer necessary to rely exclusively on unique keys for identifying, grouping, and deleting data from the cache. Summary With all these new features hot off the press, it’s time to try the new .NET 9 HybridCache! To get started or learn more, visit the documentation. The post Hello HybridCache! Streamlining Cache Management for ASP.NET Core Applications appeared first on .NET Blog. View the full article
    • Welcome to our combined .NET servicing updates for March 2025. Let’s get into the latest release of .NET & .NET Framework, here is a quick overview of what’s new in these releases: Security improvements This month you will find CVEs that have been fixed this month: CVE # Title Applies to CVE-2025-24070 .NET Elevation of Privilege Vulnerability .NET 9.0, .NET 8.0 .NET 8.0 .NET 9.0 Release Notes 8.0.14 9.0.3 Installers and binaries 8.0.14 9.0.3 Container Images images images Linux packages 8.0.14 9.0.3 Known Issues 8.0 9.0 Release changelogs ASP.NET Core: 8.0.14 | 9.0.3 Entity Framework Core: 9.0.3 Runtime: 8.0.14 | 9.0.3 SDK: 8.0.14 | 9.0.3 Winforms: 9.0.3 Share feedback about this release in the Release feedback issue. .NET Framework March 2025 Updates This month, there are no new security and non-security updates. For recent .NET Framework servicing updates, be sure to browse our release notes for .NET Framework for more details. See you next month That’s it for this month, make sure you update to the latest service release today. The post .NET and .NET Framework March 2025 servicing releases updates appeared first on .NET Blog. View the full article
    • Want to get started with AI development, but not sure where to start? I’ve got a treat for you – we have a new AI Chat Web App template now in preview. This template is part of our ongoing effort to make AI development with .NET easier to discover and use, with scaffolding and guidance within Visual Studio, Visual Studio Code, and the .NET CLI. https://devblogs.microsoft.com/dotnet/wp-content/uploads/sites/10/2025/03/AI-Template-Preview.mp4 Please note that this template is in preview, and future versions may change based on your feedback and the rapid advancements in AI. Install the template now To get started with the first Preview of the template, you install the Microsoft.Extensions.AI.Templates from your Terminal. Just run: dotnet new install Microsoft.Extensions.AI.Templates Once installed, the template is available in Visual Studio, Visual Studio Code (with the C# Dev Kit), or you can just run dotnet new aichatweb to create it in your working directory. Getting Started with the .NET AI Chat Template The .NET AI Chat template is designed to help you quickly build an AI-powered chat application to start chatting with custom data. This initial release focuses on a Blazor-based web app, built using the Microsoft.Extensions.AI and Microsoft.Extensions.VectorData abstractions. The template uses the Retrieval Augmented Generation (RAG) pattern commonly used for chat applications. Key Features and Configuration Options Chat with Custom Data: The template allows you to create a chat-based UI that can interact with sample PDFs or your own data using the RAG pattern. Local and Azure Integration: The template supports both a local vector store for prototyping and Azure AI Search for more advanced configurations. Customizable Code: The generated code includes UI components for chat interactions, citation tracking, and follow-up suggestions. You can customize or remove these components as needed. Data Ingestion: The template includes code for data ingestion, caching, and processing, allowing you to handle various data sources and formats. Using the template in Visual Studio Once the template is installed from the command line, you can find the template in Visual Studio by using the File > New Project… menu. You can search for AI Chat, or choose the AI project type to find the template: After choosing your project name and location, you can select an AI model provider and vector store to get started. By default we’re using GitHub Models with a local vector store, which is the easiest way to get started with minimal setup. You can learn about each of the options from the .NET AI Templates documentation. Using Visual Studio Code and the C# Dev Kit To use the template in Visual Studio Code, first install the C# Dev Kit extension. Then, use the .NET: New Project… command: By default this will create a new project using the GitHub Models model provider and a local vector store. You can learn about additional options from the .NET AI Templates documentation. Chatting with your own data This template includes two sample PDF files and an example of data ingestion code to process the PDFs. This data ingestion code is flexible so that you swap out the sample PDFs. To chat with your own data, do the following: If you have your project running, stop it. Remove the sample PDF files from the /wwwroot/Data folder. Add your own PDF files to the /wwwroot/Data folder. Run the application again. On startup of the app, the data ingestion code (located in /Services/Ingestion/DataIngestor.cs) will compare the contents of the Data folder; it will remove old files from the configured vector store and add new ones. Note: depending on how many files you have, and how big they are, you may run into quota and rate limits with your configured AI model provider. When you hit a limit, you may see an error message or experience long delays in the startup of the application. See the AI Template Documentation for help troubleshooting. Extending the chatbot’s behavior The code is built using Microsoft.Extensions.AI, which makes it very straightforward to plug in custom behaviors. You can give the chatbot access to call any C# function. This can extend its capabilities to include retrieving additional data or taking actions. As a very simple example, you can try giving it access to “weather” data. In Pages/Chat/Chat.razor, define a C# function in the @code block: private async Task<string> GetWeather([Description("The city, correctly capitalized")] string city) { string[] weatherValues = ["Sunny", "Cloudy", "Rainy", "Snowy", "Balmy", "Bracing"]; return city == "London" ? "Drizzle" : weatherValues[Random.Shared.Next(weatherValues.Length)]; } Then, inside the OnInitialized method, update chatOptions.Tools to include your method: chatOptions.Tools = [ AIFunctionFactory.Create(SearchAsync), AIFunctionFactory.Create(GetWeather) ]; Now try setting a breakpoint inside GetWeather and ask the chatbot about the weather. You’ll find it will call your method and will use the result in its answer. You can use this to retrieve any information from external systems, including via asynchronous calls. Bear in mind that the parameters passed in from the LLM should be treated as untrusted input. See it in action Check out the latest episode of the .NET AI Community Standup as Alex, Bruno, and Jordan overview the new templates! What’s Coming Next – Share Your Thoughts In future releases, we plan to expand the template offerings to include an AI Console template, Minimal API template, support for .NET Aspire, and including the templates by default in the .NET SDK. We’ll also be exploring support for Azure AI Foundry and working with the Semantic Kernel team to expand template options for Semantic Kernel users. We want to learn from you and use your feedback to help us shape these templates. Please share your thoughts about the template – both what works well for you, and what you’d like to see change! Thank you and happy coding! The post .NET AI Template Now Available in Preview appeared first on .NET Blog. View the full article
    • Learn what is new in the Visual Studio Code February 2025 Release (1.98) Read the full article View the full article
  • Member Statistics

    • Total Members
      47758
    • Most Online
      704

    Newest Member
    Arena Properties
    Joined
  • Forum Statistics

    • Total Topics
      31.9k
    • Total Posts
      126.2k
  1. .Net
  2. .Net
  3. .Net
  4. .Net
    • 0 replies
    • 93 views
    VS Code
  5. .Net
    • 0 replies
    • 203 views
    .Net
  6. .Net
    • 0 replies
    • 229 views
    .Net
    • 0 replies
    • 278 views
    .Net
    • 0 replies
    • 267 views
    .Net
    • 0 replies
    • 292 views
    .Net
  7. .Net
    • 0 replies
    • 254 views
    VS Code
  8. .Net
  9. .Net
  10. .Net
    • 0 replies
    • 237 views
    .Net
    • 0 replies
    • 274 views
    VS Code
  11. .Net
  • Who's Online   0 Members, 0 Anonymous, 75 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...