Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param($sln, [Switch]$revert)
- $slnContent = [IO.File]::ReadAllText($sln);
- $projects = [Text.RegularExpressions.Regex]::Matches($slnContent, "Project\(`"\{.*?\}`"\) = `".*?`", `"(.*?)`"");
- $skips = @("Solution Items");
- $cd = [IO.Path]::GetDirectoryName($sln);
- Write-Host $cd;
- foreach ($project in $projects) {
- $csproj = $project.Groups[1].Value;
- if ($skips -contains $csproj -or $csproj.Contains(".") -eq $false) {
- continue;
- }
- $fullPath = $cd + "\" + $csproj;
- $resolved = new-object IO.FileInfo $fullPath;
- Write-Host $resolved.FullName;
- if ($resolved.Exists -ne $true) {
- throw "bad resolved path";
- }
- $preUnsign = $resolved.FullName + ".unsign.revert";
- if ($revert) {
- copy $preUnsign $resolved.FullName;
- Write-Host "reverted " + $resolved.FullName + " from " + $preUnsign;
- } else {
- $content = [IO.File]::ReadAllText($resolved.FullName);
- [IO.File]::WriteAllText($preUnsign, $content);
- $content = $content.Replace("<SignAssembly>true</SignAssembly>", "<SignAssembly>false</SignAssembly>");
- [IO.File]::WriteAllText($resolved.FullName, $content);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement