TeamCity already has a dependency defined for - c#

Let me start out by saying, I am completely new to TeamCity.
The project I am building was built with VS 2013, so I have my Nuget version set to 2.8.6. I saw in some other posts that this issue normally happens from not running the latest nuget package, but this is the latest compatible package I can use.
The project builds completely fine in Visual studio but the build fails every time in TC at this line. The 30 or 40 packages prior to this install successfully
[Exec] C:\TeamCity\buildAgent\work\52c756fe2f1d3d74\OPIS\.nuget\NuGet.targets(100, 9): 'JSNLog' already has a dependency defined for 'Newtonsoft.Json'.[08:09:38]
[Exec] C:\TeamCity\buildAgent\work\52c756fe2f1d3d74\OPIS\.nuget\NuGet.targets(100, 9): error MSB3073: The command ""C:\TeamCity\buildAgent\work\52c756fe2f1d3d74\OPIS\.nuget\NuGet.exe" install "C:\TeamCity\buildAgent\work\52c756fe2f1d3d74\OPIS\OPIS\packages.config" -source "" -NonInteractive -solutionDir "C:\TeamCity\buildAgent\work\52c756fe2f1d3d74\OPIS\ "" exited with code 1.
I have tried reinstalling JSNlog and Newtonsoft.Json in my VS project, cleaning all files within TC and still, removing the project from TC as a whole and redoing the build steps and I get the same error

I have solved same problem by upgrading Nuget in TeamCity.
You have to log as system administrator.
Go to panel Administration
Go to Integrations->Nuget-> Tab Nuget.exe
Button Fetch Nuget -> choose a version superior than current and set as default
Check in your build configuration if step nuget pack uses new version of nuget, and run!
Mine was 2.8.0, now is 3.4.3

Related

MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore

ISSUE
The Visual Studio Build task in a Visual Studio Team Services build for a solution that contains a default ASP.NET MVC website and a default Unit Test Project is failing to find references. This task runs after a NuGet Restore that should install these references, but even though the NuGet Restore task succeeds, the references are not installed on the server running this build.
Visual Studio Team Services Logs
The error logs have been uploaded to This Github Repository
Attempted Fixes
In an effort to ensure that the packages are properly referenced by the project, all of the NuGet packages were reinstalled from Package Manager using the following command:
PM> Update-Package --reinstall
This only caused MSBuild to not find Microsoft.Net.Compilers.props in both the projects. So in an attempt to correct this, the version of Microsoft.Net.Compilers.props in the project was dropped to version 2.3.2. However, this only brought back the original errors where the MSTest.TestAdapter.props and Microsoft.Net.Compilers.props references could not be found.
Try it with these tasks (works fine for me with the sample solution you shared):
NuGet Tool Installer (Version of NuGet.exe to install: 4.3.0)
NuGet restore (Choose 2.* version)
Visual Studio Build (Visual Studio Version: Latest)
Queue build with the agent that has VS2017 installed.

Visual Studio 2015 enable MVC 4 support

I have an ASP NET MVC 4 project that "works on my machine(old)". When I load a project in a fresh installation of VS 2015(on a new laptop) - a lot of assemblies are missing and when I try to build the project it complains that classes like ActionResult, Controller are missing.
I checked that on the old laptop the missing dependencies are coming from C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies. On the new laptop I have only the xml descriptors of the packages but not the dlls.
What I have to install to use MVC 4 in Visual Studio 2015?
Edit: missing dependencies are:
System.Web.Helpers
System.Web.Mvc
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
I Recommend getting them again from Nuget for your ActionResult Issue its Microsoft.AspNet.Mvc which is making issue.
Open Package Manager Console and insert the command below:
Install-Package Microsoft.AspNet.Mvc
Nuget has this feature that allows you to restore all the missing Assemblies which exists in nuget. you can try that out as well.
Anyway for the rest of them install these packages below as well:
Install-Package Microsoft.AspNet.WebHelpers
Install-Package Microsoft.AspNet.WebPages
Install-Package Microsoft.AspNet.Razor
Check if you have install update 3 for VS2015
also check if Microsoft web developer tools are installed correctly
I have had the same issues when using source control or moving projects from one PC to another.
There is a work around that I use quite often and it works.
Go to YourProjectFolder -> packages.
Remove all the folders except for the xml, repositories.xml, file which is the xml config file for packages downloaded from Nuget.
On your solution in Visual Studio Right click and select Enable Nuget Packages Restore.
Then build the application it will re-download all the required packages.
Hope this helps
For Me what solved the issue is to install ASP.NET MVC 4 for Visual Studio 2010 from Microsoft Web Page

Nuget Restore via build server "unable to find version"

I have a VS solution and as part of a TeamCity Build, we restore packages from both a private NuGet feed (myget) and the public feed (nuget.org). Most packages restore fine, but it hangs on the ones below for WebApi and Mono.Security. This is all working locally in Visual Studio.
[restore] NuGet command: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\JetBrains.TeamCity.NuGetRunner.exe C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCity\buildAgent\work\953bd084b49f7d88\DataFinch.Web.sln -Source https://www.myget.org/F/datafinch/auth/<hidden>/api/v2 -Source https://api.nuget.org/v3/index.json
[11:41:35][restore] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script473789219385667038.cmd
[11:41:35][restore] in directory: C:\TeamCity\buildAgent\work\953bd084b49f7d88
[11:41:35][restore] JetBrains TeamCity NuGet Runner 8.0.37059.9
[11:41:35][restore] Registered additional extensions from paths: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\plugins-2.8
[11:41:35][restore] Starting NuGet.exe 2.8.50926.602 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Core'.
[11:41:43][restore] Unable to find version '3.2.3.0' of package 'Mono.Security'.
[11:41:43][restore] Unable to find version '6.0.4' of package 'Newtonsoft.Json'.
[11:41:43][restore] Process exited with code 1
Teamcity config:
Try using https://www.nuget.org/api/v2instead of https://api.nuget.org/v3/index.json per the nuget docs: https://docs.nuget.org/consume/Command-Line-Reference.
The reason why the build failed, was an old version of nuget.exe. I finally solved this problem by downloading the latest version and put this executable in the Program Files x86 folder. Then I created a new system variabele to point to this executable. After that I add a NuGetInstaller package in my TFS Build Definition to let me configure TFS using this new NuGet.exe.
This link helped me to let TFS use this new NuGet version
I followed this: https://blogs.msdn.microsoft.com/tfssetup/2017/04/18/tfs-2017-update-1-nuget-restore-task-always-fails-trying-to-find-packages-even-though-they-exist-on-the-feed/
I had tried 3.3 and got this error:
Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3.
WARNING: Unable to find version '3.5.0.2' of package 'Antlr'.
I downloaded the latest NuGet 4.3.0.4406 and set the Custom path to NuGet and that failed as well.
Surprisingly when I switched to 3.5 it worked.
If you are really stuck, run the command in a Command Line Prompt and it will work:
C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\1\s\xyz.sln
I ran into this problem with one of our build slaves leveraging TFS and Visual Studio.
The way I fixed it was, I opened the solution that wasn't compiling in Visual Studio, right-clicked on the SLN and selected "Enable Restore NuGet Packages"
That prompts a dialog box that you have to accept. After you've done that, you might be good to go. Right-click on the SLN again and run "Restore NuGet Packages", and if that operation succeeds, you're golden.
There's probably some setting you can adjust programmatically when setting up your slave environments, but that's one direct way to fix this kind of problem.
According to THIS current document as of this writing from MS, the proper url is: https://api.nuget.org/v3/index.json
So I went about to fix the issue because I assumed it had nothing to do with the URL. I did 2 things, not sure which it was that resolved the issue but I'll post both here in case it helps someone.
Within TFS2018 and within my build step for the installation of Nuget I specified version 4.9.3 (the reason I chose 4.9.3 because I noticed by looking at detailed log of VS that during my build it was using this version) and chose to always download the latest version.
Second thing I did was I removed a Nuget.Config file from my project that was left over from something I was testing. Then I re-commited my changes to TFS
After I did both of the above steps the rest of my build started working.
Using an old version of Visual Studio's Nuget
Visual Studio has C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\Nuget.exe. Jenkins was using that to nuget restore
Updated Nuget in program files,
C:\Program Files (x86)\NuGet> ./nuget.exe update -self
Pointed Jenkins at that new Nuget path and 🔥cooking with gas🔥
SET PATH=%PATH%;C:\Program Files (x86)\NuGet
nuget restore SolutionName.sln

'EntityFramework 6.1.3' already installed. Failed to add reference to 'System.ComponentModel.DataAnnotations'

My winforms solution was working, but when I re-opened it, some of the references were no longer working. Hence I removed all the references in the project including the references to microsoft dlls.
Now I am trying to add back the references.
What should I do first?
I tried using package manager to add Entity Framework, but got an error.
'EntityFramework 6.1.3' already installed. Failed to add reference to 'System.ComponentModel.DataAnnotations'.
Now When I open package manager, and select On Line, Entity Framework is ticked. However when I select Installed Packages it states "No packages are installed in the current solution"
When I try to build I get an error message
Error 1 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 E:\EShared\devnet10\SBD.Scheduling\\.nuget\NuGet.targets. E:\EShared\devnet10\SBD.Scheduling\SBD.Scheduling.Core\SBD.Scheduling.Core.csproj 117 5 SBD.Scheduling.Core
I tried adding a reference to System.ComponentModel.DataAnnotations but it shows in the references with a little yellow exclamation mark.
When I double click the reference icon in solution exporer I get the message
The project cannot be viewed in the object browser because it is unavailable or not yet built
After using version control to revert back to my version with EF6.0.2 , I was then able to install 6.0.3 successfully.
I would still like to know what went wrong.
Close your Visual studio.
From the Start screen, right-click the Windows PowerShell app tile (or search for it in the search bar).
Click Run as administrator (Very Important).
Run this command:
Set-ExecutionPolicy Unrestricted
Now go back to your visual studio and download your Nuget package(s).
Run this command to set it back to secure setting:
Set-ExecutionPolicy Restricted
You can use this command from the Package Manager Console:
Update-Package –reinstall EntityFramework
If you just want to reinstall everything that is defined in packages.config, use this command:
nuget install packages.config
It will also restore the missing packages.

Teamcity failing to install packages via nuget

SOLVED - PLEASE SEE COMMENT
I have a project on team city that is failing to install the required packages.
This has has worked for over a year but this week all builds started failing.
my development process is as follows:
We use github and develop locally using visual studio. We have a windows teamcity agent that does our compiling, and a teamcity server that automatically runs builds.
I get this Error on a build:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(902, 9): error MSB3073: The command "nuget install C:\BuildAgent\work\MyProject\MyLibaries\Gelf4Net\Gelf4net\packages.config -o C:\BuildAgent\work\MyProject\MyLibaries\Gelf4Net\Gelf4net\Packages" exited with code 1.
In my packages.config i have the following packages i need to install:
package id="log4net" version="1.2.11"
package id="Newtonsoft.Json" version="4.5.10"
package id="RabbitMQ.Client" version="2.8.7"
I have read through many topics on the net and have tried the following:
removed all package folder from teamcity nuget (force new packages to be downloaded)
updated nuget to latest version (2.5)
re added all the references to the project and pushed
re added the project to teamcity
enabled and disabled nuget on teamcity
added the new nuget 2.5 to teamcity
If I run "nuget install C:\BuildAgent\work\MyProject\MyLibaries\Gelf4Net\Gelf4net\packages.config -o C:\BuildAgent\work\MyProject\MyLibaries\Gelf4Net\Gelf4net\Packages" on the build agent it works and installs the packages.
The projects build and run locally.
Please any suggestions or help is appreciated
I have found the issue, our projects incude many other projects and unless the packages in each project are on the same version, teamcity will fail to build

Categories

Resources