Ronnie
Ronnie

Reputation: 1079

Quick way to determine which projects in a VS solution target a specific version?

I have a visual studio solution with a large number of projects in it, some of which target .NET v2.0, and some of which target v3.5.

I know I can right click on each project in turn to see which version it targets, but this would take for ever.

Does anyone know a quicker way I can determine which projects target v2.0 and which target v3.5?

EDIT:

I was hoping to be able to use the TargetFrameworkVersion node to determine the version, but some of the project files don't have this node, e.g.

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{E11A268C-9F62-4970-9338-129C35AD2354}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>BusinessEntities</RootNamespace>
    <AssemblyName>Business Entities</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="SomeClass.cs" />
    <Compile Include="SomeOtherClass.cs" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

...but if I right click on the project in VS, it says that the target version is .NET v2.0. Also just to be clear, I need to repeat this process for a number of solutions, so doing it the manual way is a really undesirable option.

Thanks

Upvotes: 0

Views: 335

Answers (1)

user1108948
user1108948

Reputation:

There is a link might be helpful. You have to write your own code to parse project files to get the framework versions.

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 

The other option is to use command line for the solution folder. Use MS DOS command:

findstr "<TargetFrameworkVersion>" *.csproj

The result will be displayed on the screen.

UPDATE:

Because older progjects don't contain this line. We can use another command, which search files don't contain the line.

findstr /v "<TargetFrameworkVersion>" *.csproj

Upvotes: 1

Related Questions