-
-
Save mviranyi/b55d87557a580c9b47dd to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
using System.Collections.Generic; | |
using System.Collections; | |
using System; | |
class RXSolutionFixer : AssetPostprocessor | |
{ | |
private static void OnGeneratedCSProjectFiles() //secret method called by unity after it generates the solution | |
{ | |
string currentDir = Directory.GetCurrentDirectory(); | |
string[] csprojFiles = Directory.GetFiles(currentDir, "*.csproj"); | |
foreach(var filePath in csprojFiles) | |
{ | |
FixProject(filePath); | |
} | |
} | |
static bool FixProject(string filePath) | |
{ | |
string content = File.ReadAllText(filePath); | |
string searchString = "<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>"; | |
string replaceString = "<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>"; | |
if(content.IndexOf(searchString) != -1) | |
{ | |
content = Regex.Replace(content,searchString,replaceString); | |
File.WriteAllText(filePath,content); | |
return true; | |
} | |
else | |
{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment