Visual Studio 2017 Migrating packages.config to PackageReference - visual-studio-2017

When migrating packages.config with Newtonsoft.Json package to the PackageReference csproj format I get compatibility issue:
Newtonsoft.Json v10.0.3, install.ps1 script will be ignored when the package is installed after the migration.
Is this anything which could break something? The project compiles well in local VS 2017. But TeamCity Visual Studio (sln) build fails with the error namespace name Newtonsoft could not be found. Can this be related somehow to the migration issue?

Per #Peska's comment I've checked the NuGet version which was used for the Restore build step in TeamCity. The used NuGet version was 3.4.3.
Once this was changed to Nuget 4.3.0 the package restore worked as expected and the following "Build Solution (sln)" step then succeeded.

Related

"error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found" when trying to install npm module scrypt

I´m trying to install the npm module scrypt.
I know scrypt requires node-gyp, i installed it globally (several times). Also I know node-gyp requires python 2.7 and MS Build Tools. I installed the latest python 2.7 build and i installed MS Build Tools. I also tried with VS Community Edition 2017. I tried to repair and reinstall both.
I also installed npm package windows-build-tools (several times) globally successful.
But wenn i try npm i scrypt i got the following errors:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5):
error MSB8020: The build tools for v141 (Platform Toolset = 'v141')
cannot be found. To build using the v141 build tools, please install
v141 bu ild tools. Alternatively, you may upgrade to the current
Visual Studio tools by selecting the Project menu or right-click the
solution, and then selecting "Retarget solution".
[c:\project\node_modules\scrypt\build\copied_files.vcxproj] C:\Program
Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5):
error MSB8020: The build tools for v141 (Platform Toolset = 'v141')
cannot be found. To build using the v141 build tools, please install
v141 bu ild tools. Alternatively, you may upgrade to the current
Visual Studio tools by selecting the Project menu or right-click the
solution, and then selecting "Retarget solution".
[c:\project\node_modules\scrypt\build\scrypt_wrapper.vcxproj]
Any tips or suggestions?
After a few more hours, i found out there was an old installation of visual studio 2015. I had to uninstall it first. I have no clue, why not the newest instance of build tools was used.
After this, and downgrading Node to v8, scrypt could be installed and compiled again.
I guess what fixed it for smonkey, who uninstalled an older installation of Visual Studio, was that that uninstall process also removed that old MSBuild path from %PATH%.
Because for me, just removing that old MSBuild.exe from the path fixed it. node-gyp does not need MSBuild on the path, but it gets tripped up if there is one on the path that's too old for the build target.
So either delete your MSBuild path, or make sure it points to the latest version. Unless of course you wanted to uninstall Visual Studio anyway, but that is not an option for some.
Just had this issue. Removing (or unsetting) the VCTargetsPath system variable fixed it for me. I think it was created by a previous VS2015 install, but removing VS2015 did not remove the variable.
(Ken Pespisa already posted this in a comment, but I missed it on a previous visit to this page. I am adding it as an answer so people can find it more easily.)

NuGet packages not restore in visual studio 2017

I have Asp.netCore solution which was working fine on Visual Studio 2015 and then i moved to Visual Studio 2017. Now the problem is that in Visual Studio 2017 on every nuget packages there is yellow exclamation mark. Following are solution which i have tried so far.
I'm using Visual Studio Version: 15.3.1
Run as 'Administrator' and restore package.
Clear All Nugget Cache(s) from Tools > options > NuGet Package Manager > and again restore Nuget.
Note: I have searched and found following solution and tried but did not resolve my issue.
Solution 1
I found the answer on another thread here and credit should go to #AxelWass although he did not specifically focus it towards this, it absolutely fixes this issue. The above answer did not.
I had the same issue and solve it by opening the project in a text editor and deleting the following section:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use 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\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
Once this is removed, it will resolve this nightmare issue that VS2017 and PM seems to be unable to resolve. I too have run into this multiple times - especially when I blend many projects in the same solutions directory.
As mentioned in Microsoft Installing and reinstalling packages with package restore Documentation, you should Update-Package -reinstall:
Update-Package -reinstall -ProjectName <project> command where
is the name of the affected project as it appears in
Solution Explorer. Use Update-Package -reinstall by itself to restore
all packages in the solution.
If you still have the error, try edit your project file, check if there is A path refrence error there, also check the project/solution nuget config file.
By default, new installation of visual studio did not configure package source to search packages online. That caused the problem.
I found the answer with a little bit more work from a stackoverflow link: https://stackoverflow.com/a/32360953/1503372.
That answer mentions to use "https://www.nuget.org/api/v2" url to restore packages. When I opened the package manager console in visual studio 2017, I found it was searching for packages from my PC only (offline search).
I then added "https://www.nuget.org/api/v2" url as a source for restoring packages and it worked.
Follow below steps to add a package source.
Right click project > Manage nuget package and you will see "package source label".
Add highlighted URL to package source.
Select "All" as package source.
Once you have configured your visual studio to search for packages online, your all packages will be restored.
I discovered a wrong configuration in the nuget.config. I don't know why, in this file there are some exclusion for my current project.
You can see your global configuration running this command in File Explorer
%AppData%\NuGet\NuGet.Config

AnkhSVN not showing in Visual Studio 2017

I cannot see AnkhSVN as an option under "Tools - Options - Source Control" in Visual Studio 2017. I have uninstalled and reinstalled AnkhSVN, but no effect.
Is there a way to fix this?
I came here looking for an answer to the same question. I am Running Windows 10 Enterprise and had VS2015 with AnkhSVN working before and after installing VS2017, but in VS2017 AnkhSVN was not available under SCC Plug-In Selection (even after uninstall and reinstall of the install executables downloaded from http://ankhsvn.open.collab.net, which offer registration against VS Dev15/2017).
This is what eventually worked:
Removed AnkhSVN (Windows: Add or Remove Programs)
Installed AnkhSVN Nuget package (Visual Studio: Tools/Extensions and Updates)
So the trick I believe is to "remove program installed by MSI/EXE followed by install extension via Visual Studio VSIX".
I was also subsequently able to upgrade AnkhSVN (2.7.12815 from VSIX install), by running the downloaded EXE installer for the latest daily build (2.7.12821), after which AnkhSVN is available in both VS2015 and 2017, although I had to reselect it in 2015.
I had the same issue with VS2017 and tried the solution provided by AlanK to no avail.
Here is the solution that solved the problem for me:
https://developercommunity.visualstudio.com/content/problem/119486/on-fresh-installation-extensions-are-not-working.html
Uninstall the source control plug-in.
Make a backup of the following files:
C:\USERS\USERNAME\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_XXXXXXXX\privateregistry.bin
C:\USERS\USERNAME\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_XXXXXXXX\privateregistry.user.bin
Remove these files:
C:\USERS\USERNAME\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_XXXXXXXX\privateregistry.bin
C:\USERS\USERNAME\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\15.0_XXXXXXXX\privateregistry.user.bin
Start Visual Studio 2017.
Install the source control plug-in.
You have to install "Ankh.VS15Package.vsix" package along with AnkhSVN software in your system as the version of AnkhSVN that you are installing might be supporting only up to Visual Studio 2015 or less. I had the same issue and resolved it by installing the package mentioned.
I had a similar issue after one of the Visual Studio 2017 updates. I had Visual Studio running and I was attempting to follow #AlanK's steps. I uninstalled as in Step 1. When I did Step 2, VS said the plugin was installed already. I restarted Visual Studio, thinking it was confused about the fact I uninstalled via Add/Remove programs.
I checked again and the AnkhSVN plugin was shown as disabled. I enabled it and then AnkhSVN and VS 2017 started playing nicely again.
I read the answer from Snehlata Shaw, and I think what I uninstalled from Add/Remove programs is the 2015 and earlier version of AnkhSvn. I can't be 100% sure that uninstalling it did or did not help with the 2017 version.
In summary, make sure the plugin isn't just disabled. VS 2017 says (now that is enabled) that AnknSvn slows down startup by 6 seconds and perhaps I disabled it not realizing what I was doing (Monday morning??).

NuGet restore on a TFS2013 from a VS2017 solutioin not working

I have run into the problem that if I have a VS2017 solution and try to build it on our TFS2013 build server it fails by not restoring the nuget-packages. If I convert this 2017 solution to VS2015 and check it in, and build it, the nuget-packages get restored.
I have tried with packages from both nuget.org and from internal nuget packages sources. So there is something that has changed between VS2017 and VS2015 regarding the automatic restore of nuget-packages. But I can't find the solution for it. Anybody else that has run into this problem...
If you're building a .net core project, it do have difference between VS 2015 and VS 2017. Install nuget packages in the .net core project in VS 2015, it uses packages.config file. But in VS 2017, it does not using packages.config file any more.
You need to create a batch file, to run a dotnet restore command to restore nuget packages for your solution.
code:
dotnet restore %TF_BUILD_SOURCESDIRECTORY%\...\WebApplication1Core
You'd better using VS 2017 on your build agent to build your solution. You could refer to the last reply in this thread about using VS 2017 in XAML build: https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3c4fc0b-d9ee-474a-9d91-9c5810b074a2/how-to-get-vs-2017-working-with-tfs-2017-xaml-builds?forum=tfsbuild
In the end, I do suggest that you could upgrade your TFS to 2017 and using Vnext build to build your project created in VS 2017.

Visual Studio 15 Compilation Fails- clean project

I am using Visual Studio 15 Preview 3
When I create a new project (ASP.Net 5 "Empty" project) and press build all it fails to build. I get the following errors.
Severity Code Description Project File Line Suppression State
Error MSB4063 The "VsTsc" task could not be initialized with its input parameters. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 247
Error MSB4064 The "OutputLogFile" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property. WebApplication3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets 261
Any suggestions please. I have added no code, just created the project and pressed build.
If you check out the Output window contents after the build has failed, it should show the targets file path like this one:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets
Go ahead and remove the OutputLogFile attribute from the VsTsc element. This should make the build go through.
Downgrading "Microsoft.TypeScript.MSBuild" from version 2.0.6 to 1.8.11 removed the Compilation Errors.
I had a similar issue. As it turns out the VsTsc task does support OutputLogFile. When I installed the newer TypeScript nuget packages (Microsoft.TypeScript.Compiler and Microsoft.TypeScript.MSBuild) then it adds Microsoft.TypeScript.targets to the .csproj but neglects to remove the previous lines. Nuget will add lines similar to
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.props')" />
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.1.4\build\Microsoft.TypeScript.MSBuild.targets')" />
You have to manually removed the two lines pointing to :
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
The same errors were observed after installing Visual Studio Preview. Visual Studio 2015 Community addition Update 3 installed on the same computer also started getting the same errors, on a number of different Typescript solutions. I could build the same solutions on an old computer 'Visual Studio 2015 Community addition Update 1'. I then uninstall Visual Studio Preview. Errors still occurred on Visual Studio 2015 Community addition Update 3. Also then uninstalled and reinstalled community addition and the problem was resolved, and could build the project. I thought this solution may help others with the problem solving a more elegant solution I do not have the reputation points to make a comment (where this belongs).
I was having the same issue with VS2015 Community and downloading the latest version of TypeScript (Version 2.1.5 posted 1/11/17) at https://www.microsoft.com/en-us/download/details.aspx?id=48593 did the trick for me.
I had the same problem. TypeScript tools in VisualStudio 2015 and TypeScript packages attached to project had different versions that is why build failed with "The "VsTsc" task could not be initialized with its input parameters". I reinstalled TypeScript tools for VisualStudio 2015 (get older vertion) it solved my problem.
I had a similar problem.
For me the solution was:
Remove "Microsoft.TypeScript.Compiler" package
Remove "Microsoft.TypeScript.MSBuild" package
from installed packages.