Change the Target Framework for all my projects in a Visual Studio Solution

前端 未结 10 889
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 13:08

I need to change the target framework for all projects. I have many solutions with hundreds of projects.

Anything new here or do I have to change every single proje

相关标签:
10条回答
  • 2020-12-02 13:31

    A PowerShell script that I used to do mine. Admittedly bruce force-ish.

    Get-ChildItem . -Recurse -Filter *.*proj |ForEach {
        $content = Get-Content $_.FullName
        $content |ForEach {
            $_.Replace("<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>", "<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>")
        } |Set-Content $_.FullName
    }
    
    0 讨论(0)
  • 2020-12-02 13:32

    From bash:

    $find . -name "*.csproj" -exec sed -b -i "s,<TargetFrameworkVersion>[^<]*</TargetFrameworkVersion>,<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>," {} \;
    
    0 讨论(0)
  • 2020-12-02 13:33

    You can use a macro to do this, or remember that the VS project files are text files, which means a simple global search and replace can achieve the same, and is a more general technique for making the same change to lots of project files.

    First back up an existing project file, then make the change you want (e.g., change the target framework). Use WinDiff or WinMerge to compare the new project file with the back up. This will tell you the change you need to make. Then use the Visual Studio IDE's Find and Replace in Files function to make the change to all your project files.

    0 讨论(0)
  • 2020-12-02 13:35

    Target Framework Migrator by Pavel Samokha (VHQLabs)

    http://visualstudiogallery.msdn.microsoft.com/47bded90-80d8-42af-bc35-4736fdd8cd13

    0 讨论(0)
提交回复
热议问题