Pragmatically upgrading .net framework version for all projects with PowerShell
Do feel free to provide any comments/feedback to @TheRichCarey on Twitter
We had a situation where we needed to upgrade all the CSPROJ files in a solution to 4.8. The issue is that some of our solutions contain almost a hundred projects so a manual intervention would be prone to error. (plus we have multiple solutions to apply this against!)
Whilst there are a number of extensions that do this on the VS Marketplace, they seemed a little overkill for something that can surely be achieved in PowerShell? At the end of the day its a simple find-and-replace, right?
This will load the solution file, iterate over each CSPROJ referenced and then replace the current framework version with the one specified in $versionToUse
. It will then overwrite the file.
Potential improvements
This met my needs fine, but could be improved for sure! Things that it could do better are:
- Auto scan for
.sln
files. - Provide some form of report at the end
- Auto-checkout for TFS or Git (Using git CLI or TFS CLI)
One comment