owen2 / automaticpackagerestoremigrationscript Goto Github PK
View Code? Open in Web Editor NEWto help you move to automatic nuget package restore
to help you move to automatic nuget package restore
I get lots of errors like these if I run the script.
The regular expression pattern \s is not valid.
At C:\Temp\mapsui-temp-build-error\Mapsui\migrateToAutomaticPackageRestore.ps1:36 char:9
$content = $content -replace $badStuff, ""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The regular expression pattern \s.nuget\NuGet.exe = .nuget\NuGet.exe
\s*.nuget\NuGet.targets = .nuget\NuGet.targets is not valid.
At C:\Temp\mapsui-temp-build-error\Mapsui\migrateToAutomaticPackageRestore.ps1:36 char:9
$content = $content -replace $badStuff, ""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The regular expression pattern \s is not valid.
At C:\Temp\mapsui-temp-build-error\Mapsui\migrateToAutomaticPackageRestore.ps1:36 char:9
$content = $content -replace $badStuff, ""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It'd help to leave a note about each script and its purpose, as well as when to run what.
This is a great time saver otherwise!!
I get the following error when I try to run this...
At migrateToAutomaticPackageRestore.ps1:119 char:13
+ </a> <a href="/business" class="js-selected-navigation-item nav-item" dat ...
+ ~
The '<' operator is reserved for future use.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:121 char:13
+ </a> <a href="/explore" class="js-selected-navigation-item nav-item" data ...
+ ~
The '<' operator is reserved for future use.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:123 char:13
+ </a> <a href="/pricing" class="js-selected-navigation-item nav-item" data ...
+ ~
The '<' operator is reserved for future use.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:125 char:11
+ </a> </nav>
+ ~
The '<' operator is reserved for future use.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:631 char:225
+ ... hidden" value="✓" /></div>
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:662 char:11
+ <li>© 2017 <span title="0.06994s from github-fe148-cp1-prd.iad.github ...
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:662 char:23
+ <li>© 2017 <span title="0.06994s from github-fe148-cp1-prd.iad.github ...
+ ~
The '<' operator is reserved for future use.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:662 char:29
+ <li>© 2017 <span title="0.06994s from github-fe148-cp1-prd.iad.github ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'title="0.06994s from github-fe148-cp1-prd.iad.github.net">GitHub</span>' in expression or statement.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:662 char:100
+ ... ">GitHub</span>, Inc.</li>
+ ~
Missing argument in parameter list.
At C:\Users\a\Source\Repos\k\migrateToAutomaticPackageRestore.ps1:681 char:12
+ You can't perform that action at this time.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : RedirectionNotSupported
Hi.
Thank you for migrateToAutomaticPackageRestore.ps1
.
I would like to request that blank lines at the end of project files be removed.
They weren't there before Enabling NuGet Package Restore on the solution, and so they shouldn't be there when running migrateToAutomaticPackageRestore.ps1
.
Thank you.
I have tried this script and the removal of $kindaBadStuff doesn't work for me - has anyone else ran into this issue? Do here strings work with \s
I had to modify the script to work with the .vbproj in a solution I had to migrate. The import for the nuget.targets file was: . I simply added the regex below to the script to handle that situation and added it to the replacement loop
$simpleBadStuff = @"
"@
It could be nice to use an array to hold each replacement expression and loop through each of them for each file.
xUnit.net's nuget package adds some package restore junk (maybe?) to the csproj files that it is installed into.
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
</Target>
The migration script removes this block from all csproj files that it touches, but I'm not sure if this is actually desirable? Could it potentially break things like Update-Package when a newer version of xUnit.net becomes available? Maybe MSBuild should fail when the package is not found?
Running migrateToAutomaticPackageRestore.ps1
doesn't remove the following line in the project files:
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
That line is added when Enabling NuGet Package Restore on the solution in Visual Studio 2013 Update 5 and NuGet Package Manager v2.8.60723.765.
Thank you.
I get two empty new lines at the end of the csproj files, why don't we use [IO.File]::WriteAllText()
instead of out-file so that we can get rid of the new lines issue. Is there any particular reason of not using [IO.File]::WriteAllText()
?
According to the article that you based the script on, you're supposed to remove the true line from project files. It seems to be missing from the list of regular expressions.
When I execute this script it is looping all directories, can I limit this to a folder by mentioning some path like "C:\XYZ" find all .csproj and .sln in that folder and do the rest
I have Visual Studio 2013 and 2015 installed.
I have a directory that contains Visual Studio 2013 sln files.
When I double-click on the sln files, they open in Visual Studio 2013 without issues.
However, after running migrateToAutomaticPackageRestore.ps1
on that directory, double-clicking on the sln files opens them in Visual Studio 2015.
Files with the extension sln are associated with the "Microsoft Visual Studio Version Selector".
The problem is that the sln files were originally saved using ANSI encoding, but migrateToAutomaticPackageRestore.ps1
changed them to use UTF-8 encoding and this is what caused the issue.
Re-saving the sln files back to ANSI, and then double-clicking them opens in Visual Studio 2013 as expected.
I'm thinking the script should save the files in their original encoding.
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.