Unable to find version " " of package " " - asp.net-mvc

I'm trying to deploy my website from github to Azure but there are some errors showing up every time I try to do it, this is part of the log from Azure:
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment with MSBuild.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring NuGet package Microsoft.Extensions.Caching.Abstractions.1.0.0.
Restoring NuGet package Microsoft.Extensions.Caching.Memory.1.0.0.
Restoring NuGet package Microsoft.Extensions.DependencyInjection.1.0.0.
WARNING: Unable to find version '1.0.0' of package 'Microsoft.Extensions.Caching.Abstractions'.
D:\home\.nuget: Package 'Microsoft.Extensions.Caching.Abstractions.1.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\microsoft.extensions.caching.abstractions\1.0.0\microsoft.extensions.caching.abstractions.1.0.0.nupkg'.
It does that for a lot of Nuget packages that I have, maybe all of them.
Then after the Warning messages, this other message is showed:
Restoring packages for D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'BundlerMinifier.Core' in D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in D:\home\site\repository\src\LIGMarine\project.json...
Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\home\site\repository\src\LIGMarine\project.json...
Committing restore...
Writing lock file to disk. Path: D:\home\site\repository\src\LIGMarine\project.lock.json
D:\home\site\repository\src\LIGMarine\LIGMarine.xproj
Restore completed in 5151ms.
And then comes the error messages:
Errors in packages.config projects
Unable to find version '1.0.0' of package 'Microsoft.Extensions.Caching.Abstractions'.
D:\home\.nuget: Package 'Microsoft.Extensions.Caching.Abstractions.1.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\microsoft.extensions.caching.abstractions\1.0.0\microsoft.extensions.caching.abstractions.1.0.0.nupkg'.
Feeds used:
D:\home\.nuget
D:\home\.nuget: Package 'System.Interactive.Async.3.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\system.interactive.async\3.0.0\system.interactive.async.3.0.0.nupkg'
This is a resume of the Azure log, I have read about this errors and I have created a Nuget.Config file as I show in the picture, this file is inside the Solution Items folder
This is the code that I have inside the Nuget.Config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
According to this messages, the Nuget packages cannot be found...
Feeds used:
D:\home\.nuget
D:\home\.nuget: Package 'System.Interactive.Async.3.0.0' is not found on source 'D:\home\.nuget'.
https://api.nuget.org/v3/index.json: Could not find file 'D:\home\.nuget\system.interactive.async\3.0.0\system.interactive.async.3.0.0.nupkg'
Maybe it's not looking for the packages the way it should, I'm not sure what means this path: 'D:\home\.nuget\'
What should I do?
EDIT
These are the packages that are not being found, I don't think these are private packages that cannot be found within https://api.nuget.org/v3/index.json:
Microsoft.Extensions.Caching.Abstractions
Microsoft.Extensions.Caching.Memory
Microsoft.Extensions.DependencyInjection
System.Interactive.Async
System.Linq
System.Linq.Expressions
System.Linq.Queryable
System.Globalization
System.Reflection
System.ObjectModel
System.Resources.ResourceManager
System.Reflection.Extensions
System.Runtime
System.Runtime.Extensions
System.Runtime.InteropServices
Microsoft.Extensions.DependencyInjection.Abstractions
System.Threading.Tasks
System.Threading.Tasks.4.0.11
Microsoft.Extensions.Logging.Abstractions
Microsoft.Extensions.Logging.Abstractions.1.0.0
Microsoft.Extensions.Logging
Microsoft.Extensions.Options
Microsoft.Extensions.Primitives
Remotion.Linq
Newtonsoft.Json
System.Collections
System.Collections.Immutable
System.Diagnostics.Debug
System.Diagnostics.DiagnosticSource
System.Collections.Concurrent
System.ComponentModel
System.Threading
.

I have created a new website in Azure and now it works, it seems that the previous website was deploying a previous application from Github and there were some conflicts, everything works fine now

Related

fsharp compilation fails under Mono with an NuGet error

Update. With Matt Ward's help I traced this to a bad config file. The following ~/.config/NuGet/NuGet.Config works for me
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" protocolVersion="2" />
</packageSources>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
I can do the following without any problems:
/opt/mono/mono-5.2.0.196-tarball/bin/mono ~/nuget.exe install -version 2.6.4 nunit
However, when I try to compile fsharp under the same installation of Mono, I get the following error. This is in the fsharp4 branch. What might I be doing wrong, please? Many thanks.
Project "/dir/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj"
(default target(s)): Target CallFsSrGen: Created directory
"obj/proto/./" Tool
/dir/src/fsharp/FSharp.Build-proto/../../../lib/bootstrap/4.0/fssrgen.exe
execution started with arguments:
/dir/src/fsharp/FSharp.Build/FSBuild.txt obj/proto/./FSBuild.fs
FSBuild.resx Target BeforeBuild: Executing: mono
--runtime=v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore
packages.config -PackagesDirectory packages Unable to find version
'2.6.4' of package 'NUnit'. Unable to find version '2.6.4' of
package 'NUnit.Runners'. /dir/src/FSharpSource.targets: error :
Command 'mono --runtime=v4.0.30319
/dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore
packages.config -PackagesDirectory packages' exited with code: 1.
Task "Exec" execution -- FAILED Done building target "BeforeBuild"
in project
Check what version of NuGet you are using and what NuGet package sources are enabled. Either there no NuGet package sources enabled or you are using a NuGet v2 .exe with a NuGet v3 package source.
If there is no NuGet.Config file that is provided with the FSharp build source code you are using then check the package sources listed in the file ~/.config/NuGet/NuGet.config. I suspect that it only has the v3 package source https://api.nuget.org/v3/index.json which cannot be used with a NuGet.exe (v2). So you would either need to update the nuget.exe to a later version or add the NuGet v2 package source into your NuGet.Config file: https://www.nuget.org/api/v2/

How do I register a new NuGet package source with dotnet CLI on Ubuntu 14.04?

I am running .NET Core 1.1.0 on Ubuntu 14.04, with the goal of hosting my Web APIs in Docker on Ubuntu. I want to build my packages on Ubuntu, but some of the NuGet references are hosted on an internal NuGet repository (Artifactory). This works fine in VS2015 on Windows after I add the package source, but when I run:
dotnet restore
on Ubuntu, the packages hosted on the public NuGet repo download fine, but those on Artifactory fail:
error: Unable to resolve 'Mercury.BaseModel (>= 1.1.0)' for '.NETCoreApp,Version=v1.1'.
I found a NuGet config file at \home\<user>\.nuget\NuGet\NuGet.Config and added the Artifactory repository as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="3"/>
</packageSources>
</configuration>
but I am still getting the same error.
NuGet itself does not work after installing the .NET Core SDK, I am using dotnet restore as mentioned - is there similar config I must edit for the dotnet CLI (which must be using NuGet?) or is there something else I need to do?
Thanks!
Dotnet CLI restore can take -s as source feed url, so if you have Artifactory with Remote repository to nuget.org.
dotnet restore -s https://artifactory.example.com/api/nuget/nuget.org
Reference :
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore?tabs=netcore2x
https://www.jfrog.com/confluence/display/RTF/NuGet+Repositories
After all that I quickly identified 2 problems I had missed:
I had used sudo -i to run as root attempting to resolve the problem, as as a result the NuGet config I setup in my \home folder was not being picked up.
Moving back to my own logon, I then got an error:
error: Unable to load the service index for source https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local.
error: The content at 'https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local' is not a valid JSON object.
error: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
Turns out that our Artifactory NuGet repo returns XML which is NuGet v2 compliant. I changed the config file to set the repo as v2 and it is now working. So, from above, edit the file at
\home\<user>\.nuget\NuGet\NuGet.Config
adding your new repo URL, and get the version setting right:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Artifactory-DEV" value="https://theluggage-agct.gray.net/artifactory/api/nuget/nuget-institutional-development-local" protocolVersion="2"/>
</packageSources>
</configuration>

F#'s Scaffold and FsUnit/FsCheck

I'm struggling to get started with F# on Linux using ProjectScaffold.
Specifically: I can't get a project to work with FsUnit/FsCheck/xunit. I
have F# 3.1 and mono 3.12.1 and I'm on Linux (Ubuntu) x64.
I start "MyProject" with:
$ git clone --depth=1 git#github.com:fsprojects/ProjectScaffold.git
$ cd ProjectScaffold && ./build.sh
Then I add a bit of code to "src/MyProject/Library.fs":
module MyProject.X
let four = 4
And then two tests to "tests/MyProject.Tests/Tests.fs":
module MyProject.Tests.X
open Xunit
open FsUnit.Xunit
open FsCheck
open FsCheck.Xunit
open MyProject.X
[<Fact>]
let ``Two plus two is four.`` () =
2 + 2 |> should equal four
[<Property>]
let ``Sorting a sorted list is idempotent.`` (l: int list) =
let s = List.sort l
s = List.sort s
This code works on Visual Studio where I manually added FsCheck, FsUnit, anx xunit 1.9.2 (it fails with later version
for some reason). My test project on Windows/Visual Studio has this config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FsCheck" version="1.0.4" targetFramework="net45" />
<package id="FsCheck.Xunit" version="1.0.4" targetFramework="net45" />
<package id="FsUnit.xUnit" version="1.3.0.1" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" />
</packages>
So I edit paket.dependencies to add these packages and remove Nunit:
source https://nuget.org/api/v2
nuget FSharp.Formatting 2.8.0
nuget FSharpVSPowerTools.Core 1.7.0
nuget FAKE
nuget FsCheck 1.0.4
nuget FsCheck.Xunit 1.0.4
nuget FsUnit.xUnit 1.3.0.1
nuget xunit 1.9.2
nuget SourceLink.Fake
github fsharp/FAKE modules/Octokit/Octokit.fsx
Then:
$ mono .paket/paket.exe install
...and it fails because NUnit is referenced somewhere, so I delete the references in tests/MyProject.Tests/paket.references and
$ mono .paket/paket.exe install
works, but
$ ./build.sh
fails, at it cannot find references to FsCheck et al. So I assume that I need to add the references manually, so tests/MyProject.Tests/paket.references is now:
FsCheck
FsCheck.Xunit
FsUnit.xUnit
xunit
...built build.sh fails again: it cannot find FsCheck. I could not find in the paket doc how to add a local dependency (MyProject.Tests should reference MyProject), it might be done automatically.
I had this problem and it took a while for me to figure out a fix. For the project file in the Tests directory, I had to change this:
<Reference Include="FsUnit.NUnit">
<HintPath>..\..\packages\FsUnit.1.3.0.1\Lib\Net40\FsUnit.NUnit.dll</HintPath>
<Private>True</Private>
</Reference>
To this:
<Reference Include="FsUnit.NUnit">
<HintPath>..\..\packages\FsUnit\Lib\Net40\FsUnit.NUnit.dll</HintPath>
<Private>True</Private>
</Reference>
Similarly, for NUnit:
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
To:
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
The issue is that on mono, the packages don't have the version in the path but under Visual Studio they do. Once I found this fix, I created two .fsproj files for the tests and I modified the build.sh script to swap the mono-compatible one in when under mono via:
#!/bin/bash
if test "$OS" = "Windows_NT"
then
# no changes in here
else
# fix test fsproj file
mv tests/ProjectName.Tests/ProjectName.Tests.fsproj tests/ProjectName.Tests/ProjectName.Tests.fsproj.vs
mv tests/ProjectName.Tests/ProjectName.Tests.fsproj.mono tests/ProjectName.Tests/ProjectName.Tests.fsproj
# leave the script logic for mono in place
# put project files back to avoid git noticing the swap
mv tests/ProjectName.Tests/ProjectName.Tests.fsproj tests/ProjectName.Tests/ProjectName.Tests.fsproj.mono
mv tests/ProjectName.Tests/ProjectName.Tests.fsproj.vs tests/ProjectName.Tests/ProjectName.Tests.fsproj
fi
Once I made these changes the project works fine under both Visual Studio as well as mono.
I am not quite sure, I understand you: Do you have two fsproj files, one for the production code and one for the unit tests? And are you referencing FsCheck in the fsproj?
Plus, I remember an issue, where if you compile against an older version of .net and reference an assembly compiled against a newer version of .net, it will behave as though there was no reference.

TFS Can't Restore NuGet Package

I've got TFS doing some continuous integration builds. Today, it broke for one solution. It seems it can't find AutoMapper. All the other packages can be found just fine.
A couple relevant points:
None of the packages are in source control, we're letting TFS restore them.
We have an internal NuGet feed, but it doesn't seem to be a problem in other solutions, and in this solution we are still getting Entity Framework to restore - just not AutoMapper.
I tried removing and re-adding the NuGet Packages. No luck.
If I use Remote Desktop to connect to the build server and open the project in Visual Studio there, it restores the packages and builds fine.
I can build manually by executing D:\"Program Files"\"Microsoft Team Foundation Server 12.0"\Tools\Nuget.exe restore followed by msbuild MySolutoin.sln
Our TFS server is installed on our D:\ drive.
This is from the TFS Logs:
D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" -NonInteractive
Installing 'EntityFramework 6.1.3'.
Installing 'InternalPackage 1.0'.
Successfully installed 'InternalPackage 1.0'.
Successfully installed 'EntityFramework 6.1.3'.
Unable to find version '3.3.1' of package 'AutoMapper'.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln" /nr:False /fl /flp:"logfile=C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /m /p:OutDir="C:\Builds\1\MyCompany Web\FclQuoteWcfService\bin\\" /p:VCBuildOverride="C:\Builds\1\MyCompany Web\FclQuoteWcfService\src\FclQuoteWcfService.sln.vsprops" /dl:WorkflowCentralLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/230;IgnoreDuplicateProjects=False;InformationNodeId=12;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://ctidev2k8:8080/tfs/MyCompany;"*WorkflowForwardingLogger,"D:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="9aa9f8af-c9b9-4d0a-ba06-7cc959231d8e,vstfs:///Build/Build/230" /p:BuildLabel="FclQuoteWcfService_20150330.2" /p:BuildTimestamp="Mon, 30 Mar 2015 20:40:07 GMT" /p:BuildSourceVersion="LFclQuoteWcfService_20150330.2#$/MyCompany Web" /p:BuildDefinition="FclQuoteWcfService"
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I've seen this too. It seems to be triggered as soon as NuGet package restore switches to the internal feed. Once it does this is doesn't switch back to the official nuget.org feed and continues to look for the packages on the internal feed.
Ensure both package sources are added to your NuGet.config file. Also ensure both sources are 'active'.
<configuration>
<packageSources>
<add key="nuget.org"
value="https://www.nuget.org/api/v2/" />
<add key="example.com"
value="http://example.com/feed/nuget/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
See NuGet configuration file documentation.
Matt's answer put me on the right track but we don't use an internal feed so I had to do some more digging. This answer works, at least, for a project created in Visual Studio 2015 and built by TFS 2015.
In Visual Studio, open the NuGet package manager settings (Tools menu > NuGet Package Manager > Package Manager Settings). Choose "Package Sources" from the options list on the left.
Create the nuget.config file at the root of the solution. This should be the same folder location as your ".sln" solution file. Copy the following into the config file:
<configuration>
<packageSources>
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
Within the <packageSources> tag, create an <add key="" value="" /> entry for each source listed in the "Package Sources" options window. The key is the name of the source as shown above the URL, and the value is the URL itself. Include those listed in both "Available package sources" and "Machine-wide package sources". I did not create an entry for the local filesystem as it wasn't used in this solution. Based on the screenshot above, the complete config file now contains the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org"
value="https://api.nuget.org/v3/index.json" />
<add key="Microsoft and .NET"
value="https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/" />
</packageSources>
<activePackageSource>
<add key="All"
value="(Aggregate source)" />
</activePackageSource>
</configuration>
After committing the nuget.config file to source control, TFS was able to download all the necessary NuGet packages and successfully build the solution.
In addition to Matt's answer, I'd like to highlight the following well-hidden stuff from the NuGet documentation:
NuGet config files are treated in the following priority order
(closest to the folder nuget.exe runs from wins), for example assuming
the solution directory is c:\a\b\c:
c:\a\b\c\.nuget\nuget.config - This file is only used for solution
level packages, and is not supported in nuget 3.0 - 3.4
c:\a\b\c\nuget.config
c:\a\b\nuget.config
c:\a\nuget.config
c:\nuget.config
User specific config file,
%AppData%\NuGet\nuget.config.
Or the user specified file thru option
-ConfigFile.
This could explain some weird behaviour in specific scenario's where a restore does or does not pick up a configured feed, depending on whether youre restoring with nuget 2.x or 3.x
Edit: and I found yet another reason why packages might not be detected:
I have package "A" with version 1.1.1.0 .
Prior 3.4 this command works well:
nuget install A -version 1.1.1.0
With NuGet 3.4 RC I get:
An error occurred while retrieving package metadata for 'A.1.1.1' from
source 'N'. An error occurred while retrieving package metadata for
'A.1.1.1' from source 'N'. Data at the root level is invalid. Line
1, position 1.
...
The client treats 1.1, 1.1.0, 1.01.0 and 1.1.0.0 as the same version
using SemVer rules. The reason non-normalized versions were special
cased in the past is because for v2 http calls the client would first
send the version string exactly as the user specified it

Missing Microsoft.Build.Tasks.v4.0.dll on visual studio online tfs build

I am trying to build my project with visual studio online.
I am getting the following error.
C:\a\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
This is coming from the nuget.targets file in my solution.
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
I have updated nuget.exe to latest and have not changed anything in nuget.targets.
The problem was that some of the class libraries in the solution had the default value :
ToolsVersion="12.0"
changing that to
ToolsVersion="4.0"
made it work on TFS online
I ran into this after upgrading a project to .NET 4.5.2. Seems to be a conflict between the .NET 4.5 point releases and the old way to do NuGet package restore (MSBuild-Integrated package restore vs Automatic Package Restore).
I was able to solve the issue by migrating NuGet to the new way of doing package restore: http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore
More info: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

Resources