(#3835) Switch to using new csproj format#3836
Open
gep13 wants to merge 16 commits intochocolatey:developfrom
Open
(#3835) Switch to using new csproj format#3836gep13 wants to merge 16 commits intochocolatey:developfrom
gep13 wants to merge 16 commits intochocolatey:developfrom
Conversation
10 tasks
585ad5d to
da5f6ac
Compare
AdmiringWorm
reviewed
Feb 3, 2026
38a3cc3 to
6ca9d63
Compare
AdmiringWorm
requested changes
Feb 3, 2026
src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
Outdated
Show resolved
Hide resolved
5f2448d to
f9017b5
Compare
This was done in two stages. 1. Within Visual Studio, right click on the packages.config file, and use the option to Migrate packages.config to PackageRefernce... This had the effect of deleting the no longer required packages.config file 2. Use the try-convert .NET Global Tool to convert the solution and the contained project to .NET This process wasn't perfect, and fix ups had to be made on the changes that were made, and there was an element of trial and error to get to a point where things were working correctly. During testing, it was found that having an app.config within a project, especially unit test projects, was causing a problem. Where necessary, every app.config file was removed, and instead two elements were added into the csproj file to have the dotnet build create a dynamic app.config file: <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> Also during testing, it was found that it was necessary to include the following element: <Configurations>Debug;Release;ReleaseOfficial</Configurations> to ensure that each build configuration was respected. Without this in place, there was an error within Visual Studio when trying to change from one build configuration to another. A change was made in .NET where there is no longer a Target with a Name of AfterBuild, instead, this has changed to be an AfterTargets attribute, with the Name of build. Without making this change, the copying of the output assemblies to the required locations to make debugging work wasn't being done. Where possible, the number of direct PackageReferences has been pruned, to leave only the specific references that are needed, relying on transitive depdendencies to bring in the remaining packages.
This was mainly around changes in how NUnit and SimpleInjector works.
Rather than MSBuild. While this is not a requirement, and we could have continued to use MSBuild, it makes sense to make this jump now, so that it is one less thing to do once we start thinking about building for .NET, rather than .NET Framework. Due to the version of InspectCode that is currently being used in Chocolatey.Cake.Recipe, it is not possible to analyse the repository, so we have had to turn this off. This will be re-enabled, once we get an updated version of Chocolatey.Cake.Recipe, with new tool versions. Finally, the file paths were updated to reflect the new folder structures. Each project now include the target framework in the output path. We only have one at the minute, but this might change in the future.
This allows the execution of debugging of CLI with different command line parameters. The usage of source list is just as an example.
The project is now using a new version of log4net, so we need to update the nuspec file to reflect this. At some point, we should switch to building the nuget package using dotnet build, so that this manual step will no longer be required.
Due to the changes in how SimpleInjector works, in v5.5.0, we have to change some of the default values for its configuration values. This essentially puts SimpleInjector back to how it used to work, before v5.5.0. Don't really like doing this, but until we overhaul how all the registrations are done, both here, and in CLE and Agent, this is the best path forward.
We don't actually ever register a ChocolateyUnpackSelfCommand object in the IoC container. This only ever works due to the fact that SimpleInjector was doing more work than it should. Instead, we need to locate the correct command from the collection of ICommands that are registered, based on the CommandFor attribute that is applied to it. This similar to how the GenericRunner itself does it.
The chocolatey.console project had a reference to the Chocolatey.PowerShell when it wasn't needed. Before, this wasn't causing any problems, but with the uplift to the new csproj format, and the fact that it brings in transitive dependencies into a project, the fact that there is a StringResources in both chocolatey.lib and Chocolatey.PowerShell (the file is linked from one project to the other), it means that there are two references to the same thing, and as a result, as usage of StringResources is broken. Splitting the project reference seems like the correct course of action. The Chocolatey.PowerShell assembly is only used within the PowerShell execution of Chocolatey CLI, so no direct project reference should ever be needed.
When doing an official build, the snk file that is used to strong name sign the assemblies is in a different location to the default. When using the attribute in the SolutionVersion.cs file, this path was updated on each build, however, when using the csproj file properties, it is not as simply. Let's check to see whether the environment variable that stores this location has a value or not, and if it does, use that value for signing. This should mean that the paths in the SolutionVersion.cs file match what is used in the csproj files, and once we move everything into a Directory.props file, and remove the usage of the SolutionVersion.cs file completely, everything should continue to work as expected.
During testing of the changes in this PR to convert to the new csproj format, it was noticed that Unit, as well as Integtation Test results were no longer being reported into TeamCity. This is likely due to the switch to using dotnet test, and not NUnit directly. Rather than attempt to make a change to correct this issue, we are going to try using this package to report the information into TeamCity. If this works, this will need to be made across the other products as well. At some point, we may look to fix Chocolatey.Cake.Recipe, so that the requirement of this package no longer exists, but for this, its usage is the first step to getting this to work. In addition, the coverlet.msbuild package was added to ensure that we continue to get code coverage metrics, and we are also now being explicit about the fact that this is a Unit Test project, as well as adding the Microsoft.NET.Test.Sdk. While both of these are not required, we feel it is better to be explicit in this area.
During testing, one of the Pester end to end tests failed. During investigation, it was found that there must have been a change in the way that assemblies are ordered when using GetType().Assembly.GetTypes() has changed. Now, these assemblies are ordered alphabetically, and previously, they seem to be returned in the order that they were found. The test in question relied on a specific rule being returned first, and as a result, the test failed. After discussion with Kim, the decision was made to change the description of the rule to be the same as the other one, since they are essentially the same thing. Making this change results in the rule that is expected being returned, and the test should now pass.
f9017b5 to
7b848d4
Compare
AdmiringWorm
reviewed
Feb 5, 2026
Member
AdmiringWorm
left a comment
There was a problem hiding this comment.
The changes LGTM, once the test kitchen failures have been investigated, I see no problems with this being merged.
After review by Kim, there were a couple of things that were requested to be changed. * Removal of remaining x86 build configurations, which we don't believe are required anymore * Prefer use of var * Remove unnecessary attributes applied to csrpoj files, which must have been added by the TryConvert utility that was used. * Fix up launch settings so that a hard-coded path is not used. * Move away from a relative path to files, and instead make use of the $(SolutionDir) variable. This gives us some flexibility going foward to move files around on disk, without having to update lots of references to files.
There are times when the environment variable specifying the location of the official snk file will be set, but the file won't actually exist on disk. This commit makes this check more secure to ensure that the environment variable is both set, _AND_ the file exists on disk. Only then will the AssemblyOriginatorKeyFile be set to that value, otherwise, it will remain as the default value.
* Where possible, unrequired PackageReferences have been removed, since they are not needed due to transitive dependencies that exist from other packages. * The credits information for all packages have been updated to reflect the current state of PackageReferences that are now in play. In some cases, this has meant removing ones that are no longer required, adding new ones, and also updating version numbers to reflect that packages that have been updated.
This change is to reflect that the packages that are used by the project are no longer stored in the packages.config file, but rather in the project *.csproj files. We need changes to these files to be approved by the Code Owners of the repository.
This was done using the Credits Generator tool.
55782f4 to
161b991
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description Of Changes
This PR changes the chocolatey/choco repository to use the new csproj format, rather than the old csproj format.
Also, the build process has been changed to use
dotnet buildrather thanmsbuildIn addition, NuGet packages have been updated, where possible.
Build configurations have been pruned, so only the required build configurations are left in place.
Motivation and Context
Moving forward, we are going to want to build for .NET, rather than .NET Framework, and making this switch will be a requirement. For now, doing this work here, while we are still targetting net48, means that other systems, such as Renovate, will be able to be used for dependency management.
Testing
Testing of this PR should be done in conjunction with the changes in the following PR's:
All of the 5 Core Products have to continue to work together, including the ability to debug all the projects. We can't be in a position where some of them work, and others don't. They all have to work, or we can't move forward with this change.
NOTE: Due to the changes in this PR, it is NOT possible to use the
Get-ChocoUpdatedDebugVersion.ps1scripts to copy build artifacts to different locations. This process will have to be done manually, and it documented below.git clean -xfdin each product folder (to ensure that there are no stray files that could interfere with the testing.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=falsein the CLI folder, to generate build artifacts that can be copied into other repositories.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=false --target=restorein the CLE repository - to restore all the NuGet packages that are required.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=false --target=restorein the Agent repository - to restore all the NuGet packages that are required.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=false --target=restorein the GUIrepository - to restore all the NuGet packages that are required.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=false --target=restorein the GUI Licensed Extension repository - to restore all the NuGet packages that are requiredC:\code\choco\code_drop\temp\_PublishedLibs\chocolatey_mergedinto the following foldersC:\code\choco-licensed\src\packages\chocolatey.lib\2.6.0\lib\net48C:\code\choco-licensed-services\src\packages\chocolatey.lib\2.6.0\lib\net48C:\code\ChocolateyGUI\Source\packages\chocolatey.lib\2.1.0\lib\net48C:\code\chocolateygui-licensed\Source\packages\chocolatey.lib\2.1.0\lib\net48C:\code\choco\code_drop\temp\_PublishedApps\choco_mergedinto the following foldersC:\code\choco-licensed\lib\Chocolatey.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=falsein the CLE folder, to generate build artifacts that can be copied into other repositorieschocolatey.licensed.dllfile fromC:\code\choco-licensed\code_drop\temp\_PublishedLibs\chocolatey.licensed\net48into the following folders:C:\code\choco-licensed-services\src\packages\chocolatey-licensed.lib\7.0.0\lib\net48.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=falsein the Agent folder.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=falsein the GUI folder, to generate build artifacts that can be copied into other repositoriesChocolateyGui.Common.dllfile fromC:\code\ChocolateyGUI\code_drop\temp\_PublishedLibs\ChocolateyGui.Common\net48into the following folders:C:\code\chocolateygui-licensed\Source\packages\chocolateygui.common\2.1.1\lib\net48ChocolateyGui.Common.Windows.dllfile fromC:\code\ChocolateyGUI\code_drop\temp\_PublishedLibs\ChocolateyGui.Common.Windows\net48into the following folders:C:\code\chocolateygui-licensed\Source\packages\chocolateygui.common.windows\2.1.1\lib\net48C:\code\ChocolateyGUI\code_drop\temp\_PublishedApps\ChocolateyGui\net48into the following folders:C:\code\chocolateygui-licensed\Lib\ChocolateyGui.\build.debug.bat --testexecutiontype=none --shouldrunanalyze=falsein the GUI Licensed Extension folderOperating Systems Testing
Windows 11
Change Types Made
Change Checklist
Related Issue