Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
Fixed newline issue (#18)
Browse files Browse the repository at this point in the history
Fixed deleting whole EnsureNuGetPackageBuildImports target when there are additional error conditions from other packages.
  • Loading branch information
Michael Spranger committed Apr 26, 2017
1 parent 9780361 commit ada11af
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions migrateToAutomaticPackageRestore.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
########################################
# Regex Patterns for Really Bad Things!
$errorTag = "\s*<Error Condition=""!Exists\('\$\(SolutionDir\)\\\.nuget\\NuGet\.targets'\)"" Text=""\$\(\[System\.String\]::Format\('\$\(ErrorText\)', '\$\(SolutionDir\)\\\.nuget\\NuGet\.targets'\)\)"" />"
$listOfBadStuff = @(
#sln regex
"\s*(\.nuget\\NuGet\.(exe|targets)) = \1",
#*proj regexes
"\s*<Import Project=""\$\(SolutionDir\)\\\.nuget\\NuGet\.targets"".*?/>",
"\s*<Target Name=""EnsureNuGetPackageBuildImports"" BeforeTargets=""PrepareForBuild"">(.|\n)*?</Target>",
"\s*<Target Name=""EnsureNuGetPackageBuildImports"" BeforeTargets=""PrepareForBuild"">\s*<PropertyGroup>\s*<ErrorText>.*?</ErrorText>\s*</PropertyGroup>\s*$errorTag\s*</Target>",
$errorTag,
"\s*<RestorePackages>\w*</RestorePackages>"
)

Expand All @@ -24,14 +26,14 @@ ls -Recurse -include 'NuGet.exe','NuGet.targets' |
ls -Recurse -include *.csproj, *.sln, *.fsproj, *.vbproj, *.wixproj, *.vcxproj |
foreach {
sp $_ IsReadOnly $false
$content = cat $_.FullName | Out-String
$content = Get-Content -Raw -Path $_.FullName
$origContent = $content
foreach($badStuff in $listOfBadStuff){
$content = $content -replace $badStuff, ""
}
if ($origContent -ne $content)
{
$content | out-file -encoding "UTF8" $_.FullName
$content | Out-File -encoding "UTF8" -NoNewline $_.FullName
write-host messed with $_.Name
}
}

0 comments on commit ada11af

Please sign in to comment.