Skip to main content

Posts

Showing posts with the label Visual Studio 2019

Azure DevOps Server–Switch from HTTP to HTTPS–Part 2

With the release of Azure DevOps Server 2022 , I thought it would be a good time to finally make the switch to HTTPS for our internal Azure DevOps server. With the idea to minimize downtime, I decided to first introduce the HTTPS endpoint before upgrading the Azure DevOps server. But o boy, what I thought would be an easy task turned out to be quite a journey. Yesterday I explained the actions required on the server side, today we move on to the client side. Visual Studio TFVC workspaces In Visual Studio, we have to update our connections in Team Explorer. Therefore click on the green Connect icon in Team Explorer . Click on Manage Connections and Connect to a project… Right click on the existing connection and choose Remove from the context menu. Click on Add TFS server , enter the updated Server URL and click on Add . Restart your Visual Studio instance. After doing these steps, I noticed that still the original URL was shown when I re...

Your project does not reference ".NETFramework,Version=v4.6.2" framework

After playing around with the dotnet upgrade assistant(see this previous post ) I did an undo of the changes that were made by the tool through source control. However after doing that my code refused to compile. Here is the error message I got: Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFrameworks" property of your project file and then re-run NuGet restore. When I took a look at my project settings, I didn’t see something wrong… I tried a ‘Clean Solution’ , didn’t help… I deleted the bin folder and did a ‘Rebuild’ of the solution, didn’t help either… In the end what did the trick was to remove the obj folder for every project . Once the folder was removed, the error disappeared when I recompiled the application. Strange!

Azure Pipelines - Unable to determine the location of vstest.console.exe

A colleague forwarded me a question about a failing build pipeline. When I took a look at the build results, I noticed that the Visual Studio Test task was failing. Inside the logs I found more details explaining what was going on: ##[warning]No results found to publish. ##[debug]Processed: ##vso[task.logissue type=warning]No results found to publish. ##[error]System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe ---> System.IO.FileNotFoundException: Unable to determine the location of vstest.console.exe ##[debug]Processed: ##vso[task.logissue type=error;]System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe ---> System.IO.FileNotFoundException: Unable to determine the location of vstest.console.exe    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeVSTestCmdlet.GetVsTestLocation()    at Microsoft.TeamFou...

Visual Studio Solution Filters

As I do a lot of software audits for customer, I encounter a large variation of codebases, some really small; a few projects, some really big; hundreds of projects in one solution. The question is how can you avoid that Visual Studio becomes awfully slow when you have such a large solution? Enter Visual Studio Solution Filters… What are Visual Studio Solution Filters? Visual Studio Solution Filters allow you to selectively load a subset of the projects in a solution. Typically when working in a large solution you don’t need all projects. With a solution filter(.slnf) you can save a subset of projects that you want to load. How to create a Visual Studio Solution Filter?   Let’s share how to create a solution filter: Open Visual Studio . Click on the Open a project or solution option. In the file dialog, select the solution you want to load. Don’t forget to check the Do not load projects checkbox in the bottom of the dialog before hitting Open . T...

Azure Functions with built-in OpenAPI support

With the latest Visual Studio update, a new Azure Function template was added; “Http Trigger with OpenAPI”. This template will create a new function with the necessary implementation for OpenAPI support. Let’s try this: Open Visual Studio. Choose ‘Create a new Project’.  Search for the ‘Azure Functions’ template and click Next . Specify a name and location for the project and click Create . Now you can choose a specific Azure Functions template. Select the ‘Http Trigger with OpenAPI’ template and click Create . The new function is bootstrapped with the necessary implementation for OpenAPI support. Extra attributes are added on top of your Function method. When you run the function app, you can browse to ‘/api/swagger/ui’ to view the Swagger UI page.

Visual Studio 2019–Manage Docker Compose launch settings

With the latest Visual Studio update, the Docker Compose tooling got improved and it is not possible to create a launch profile to run any combination of services defined in your compose files. Before you only had once launch profile and you couldn’t choose what services to start. Let’s find out how to use this new feature: Right-click on you docker-compose project and select Manage Docker Compose Launch Settings The tooling will scan through all Compose files to find all services. Once the scanning is completed you can choose which services to launch Create a new profile by clicking New… and specify a name Now we can configure which services to launch for this profile. Also choose the Launch Service name and action . Once you are done , click OK A new launch profile is created and available to use

Visual Studio 2019 - Create a Docker compose file for an existing solution

Visual Studio makes it really easy to create a Docker compose file for an existing solution. Here are the steps to get there: Open your solution in Visual Studio Right click on one of your projects and choose Add –> Container Orchestrator Support Choose Docker compose in the Add Container Orchestrator dialog and click OK Choose Linux as the Target OS and click OK A new Docker Compose project is generated Inside this project you find a docker-compose.yml file with a reference to the project you’ve selected To add the other projects, follow the same procedure; right click on another project and choose Add –> Container Orchestrator Support again The docker-compose.yml file will be updated with the new project information

Visual Studio 2019–Editorconfig UI

As I read more code than I write, code consistenty and readability are really important for me. That is why I like the .editorconfig and one of the reasons why I blogged about it before: Introducing .editorconfig: https://bartwullems.blogspot.com/2017/04/visual-studio-2017editorconfig.html Generate an .editorconfig: https://bartwullems.blogspot.com/2019/10/visual-studiogenerate-editorconfig-file.html The ‘dotnet format’ command: https://bartwullems.blogspot.com/2020/04/dotnet-format.html Let private fields start with an underscore: https://bartwullems.blogspot.com/2019/12/editorconfig-let-private-fields-start.html Code cleanup in Visual Studio: https://bartwullems.blogspot.com/2019/10/visual-studio-2019code-cleanup.html Although I really like EditorConfig files, configuring them is not that easy. If you agree then I have great news for you! Starting from Visual Studio 16.10 an EditorConfig designer was added that allows you to easily view and configure your cod...

Visual Studio–Create your CI/CD pipeline using Github Actions

When looking through the preview features activated inside Visual Studio (Options > Environment > Preview Features) I noticed the ‘GitHub Actions support in Publish’ feature: Let’s try it to see what it does… Open the Start Window in Visual Studio. Click on the Clone a Project button. Enter the repository location and local path and click on Clone . Go to the Solution Explorer . Right click on the Solution and choose Publish from the context menu Let’s publish our Application to Azure. So choose Azure from the list of available Targets and click on Next . Now we need to choose a specific target. Let’s choose Azure App Service and click on Next . On the next screen, we need to choose the App Service Instance we want to use. After doing that, click on Next . As a last step, we need to select the deployment type. It is here that the preview feature appears, as we can choose CI/CD using GitHub Actions . Click on Finish. ...

Configure Visual Studio 2019 to use SourceLink

Source Link allows developers to debug the source code from libraries they are using. Tools like Visual Studio can step into its source code what helps you find out what is going on behind the scenes. Let’s see how we can enable SourceLink debugging in Visual Studio: Go to Tools > Options > Debugging > Symbols and check if the  ‘NuGet.org Symbol Server’ option is checked. It is recommended to specify a local directory that can be used as a symbol cache to avoid the need to download symbols every time: Disable 'Just My Code' in  Tools > Options > Debugging > General to make the debugger load symbols that are not part of your current solution. Also check that the  'Enable Source Link support' is set (which should be the case by default): When you now try to debug code, you can step into the code through F11. Visual Studio will ask you to download the corresponding source code: Troubleshooting In case you get a ‘File Dialog’ a...

Customize your build with Directory.Build.props and Directory.Build.targets

With the release of MSBuild version 15, you no longer need to add custom properties to every project in your solution. Instead you can create a single file called Directory.Build.props in the root folder of your source.When MSBuild runs, it will search for this file and loads it when found. I use this on my projects to set common properties: Directory.Build.props is imported very early in the build pipeline and can be overridden elsewhere in the project file or in imported files. If you want to override properties set in a specific project, use Directory.Build.targets instead. It is used and discovered in the same way, but it is loaded much later in the build pipeline. So, it can override properties and targets defined in specific projects. More information: https://docs.microsoft.com/nl-nl/visualstudio/msbuild/customize-your-build?view=vs-2019#directorybuildprops-and-directorybuildtargets

Visual Studio 2019 16.8– Git Amend

With the release of Visual Studio 2019 16.8 Git became the default source control experience. It no longer lives inside Team Explorer but got its own menu item. Read the announcement for more details. One of the things I noticed when using the new Git experience was the first class support for ‘git amend’ . But what does ‘git amend’ do? Let me explain… The git commit --amend command is a convenient way to modify the most recent commit. It lets you combine staged changes with the previous commit instead of creating an entirely new commit. Amending does not just alter the most recent commit, it replaces it entirely, meaning the amended commit will be a new entity with its own ref. It is a way to rewrite the git history. Warning: Avoid amending a commit that other developers have based their work on. To be safe only amend local commits.

The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future.

After upgrading to the latest Visual Studio version(16.8.1) that added support for .NET 5, I got a new warning when opening an existing .NET 3.0 solution: Severity Code Description Project File Line Suppression State Warning NETSDK1138 The target framework 'netcoreapp3.0' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. ExampleApp C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets 28 You don’t have to panic when you see this warning. The only thing you need to be...

Database profiling in Visual Studio

Visual Studio 2019 version 16.3 extends the Performance Profiler with a new ‘Database’ option.  This will enable the new Database tool that captures all database activity during your profiling session. Remark: The database tool works with .NET Core projects  using either ADO.NET or Entity Framework Core . It also works on traces collected using dotnet trace which means we can collect data anywhere that .NET Core runs (including Linux!) and analyze that data in Visual Studio. Let’s try it: Open the Performance Profiler in Visual Studio by clicking Debug > Performance Profiler. Select the checkbox next to “Database” to enable the tool. Click on Start to start the profiling session. Now interact with your application in the ways you’re interested in investigating. When you are done click ‘Stop collection’. Now you get a table of all the queries that happened during your profiling session along with a graph that shows when and how many queries h...