Click here to Skip to main content
15,887,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I already have one .net application which contains more than 50 different projects. I want to know which .net version is used by these projects. Actually all projects are developed in .net version 3.5. Now I am converting them to .net version 4.5. So instead of checking all projects version one by one, I want to check all at once. Is there any way check this?
Thanks in advance.

What I have tried:

I am checking each projects versions one by one but this is very time consuming process. Googled for the solution but can't find proper way.
Posted
Updated 3-Apr-20 4:14am
Comments
Afzaal Ahmad Zeeshan 26-Apr-17 6:49am    
Check, and then do what? Change the version from 3.5 to 4.5 one by one?

How many projects are there in that single solution?

Old question, but for anyone who ends up here...

At a Windows command line:
1. Change directory to the root of your solution.
2. Enter the following command and press ENTER:
findstr /s "TargetFrameworkVersion" *.csproj


This displays the version line from each project file. The example is for C# projects, so to search VB projects, replace "csproj" with "vsproj".
 
Share this answer
 
v2
Comments
robvon 8-Nov-23 16:42pm    
For .Net Core, the text 'Version' is no longer present.

Just search for 'TargetFramework'
Short PowerShell script:

$solutionFolder = [solution folder]
Get-ChildItem $solutionFolder -Include *.csproj -Recurse -Force | ForEach-Object {
[xml]$projectXml = (Get-Content ($_))
$namespace=New-Object System.Xml.XmlNamespaceManager($projectXml.NameTable)
$namespace.AddNamespace("nsp", $projectXml.DocumentElement.NamespaceURI)

$dotnetVersionNode = $projectXml.SelectSingleNode("//nsp:TargetFrameworkVersion", $namespace)
if ($dotnetVersionNode -eq $null) {
$dotnetVersionNode = $projectXml.SelectSingleNode("//nsp:TargetFramework", $namespace)
}
Write-Host $_ : $dotnetVersionNode.InnerXml
}

Note: This script will also identify targeted framework versions for .Net Core projects
 
Share this answer
 
Comments
Dave Kreskowiak 3-Apr-20 11:23am    
Sorry, I posted this in the wrong window...
You didn't google hard enough.

This is what you need: Target Framework Migrator - Visual Studio Marketplace[^]
 
Share this answer
 
Comments
Umesh AP 5-May-17 9:31am    
@jimmson2.4K - Thanks for your valuable solution. I will use Target Framework Migrator surely in future.
In the csProj or vbProj file for each project will be a line that looks like
XML
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
You could use a text search in files tools (such as the one that comes with the free editor NotePad++[^] to search for the phrase TargetFrameworkVersion to get a list of the versions in the project
 
Share this answer
 
One way is to write a quick app.
Each project within a solution is inside it's own folder below the main solution folder, and each project folder contains a ".CSPROJ" or ".VBPROJ" file.
That project file is an XML descriptor of the project, and contains a node PropertyGroup/TargetFrameworkVersion.
If you scan each folder, read each project file, you can pick up (or change) the framework version for all projects in the solution. Note that changing the framework version may cause compiler errors you'll need to fix, but you probably know that already!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900