(#1104) Upgrade to new csproj format#1105
Open
gep13 wants to merge 11 commits intochocolatey:developfrom
Open
Conversation
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. The opportunity was also taken to reduce the number of Platform|Configuration combinations that were in play. Simply put, this just adds now, and it isn't needed. Remaining are Debug|Release|ReleaseOfficial, and mainly only AnyCPU, unless a specific one is left, say for building of an MSI.
By default, when using the new csproj format, PackageReferences, and dotnet build, NuGet packages are restored to a global packages folder. While this does indeed save space on disk, we are not able to do this. A number of dependencies that we have are not strong name signed, and since we strong name everything in Chocolatey, we need these dependencies to be strong named signed as part of the build. Using a local packages folder makes this process much easier, and means that the change in limited in scope to each project, and not globally.
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 nuspec files and wxs file 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.
10 tasks
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.
This will need updated to the final package version once it is available, as well as bumping the nuspec version number for the dependency.
5121802 to
99d64c8
Compare
AdmiringWorm
requested changes
Feb 4, 2026
Member
AdmiringWorm
left a comment
There was a problem hiding this comment.
A couple of comments, as well as I noticed that the app.config file with assembly redirects are still available in this repository, is this intentional (considering it has been removed from other repositories)?
I am also not able to run the Chocolatey GUI locally, with an exception message that it couldn't find the resource chocolatey.png. Re-adding the chocolatey.png file makes the application run again with a problem, and I couldn't see any other issues when testing.
Pulling down trtanslations also gives a build error (In Visual Studio at least) that mentions Duplicae 'EmbeddedResource' items were included.
* Remove app.config files that are no longer required. The app.config file is now generated dynamically on each build, so maintaining this file manually is no longer required. * Remove explicit EmbeddedResource entry as this is no longer required. When there are resx files in place, i.e. after translations are downloaded from Transifex, the EmbeddedResource entries are added automatically. * 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.
4bba636 to
b8190c5
Compare
During testing of the installation of the Chocolatey GUI MSI, it was noticed that a net48 folder was being created within the Chocolatey GUI Program Files installation folder. This was not as expected, but it is as a result of the publishing of the application files into a target framework folder. To rectify this, the _GuiTargetDir and _GuiCliTargetDir variables have been updated to include the net48 target framework, rather than manually adding net48 to only certain files. By using this approach, all the previous files that were collected as part of the harvest are the same as before, rather than being havested as a single folder with everything contained within it.
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/ChocolateyGUI repository to use the new csproj format, rather than the old csproj format.
Also, the build process has been changed to use dotnet build rather than msbuild
In 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
See the testing steps in this PR.
Operating Systems Testing
Windows 11
Change Types Made
Change Checklist
Related Issue