Team Build Nuget restore failure with .NET Core 2.0 + .Net Standard 2.0 - visual-studio-2017

I have a VS2017 solution that contains a .NET Core 2.0 console project that references a .NET Standard 2.0 class library, as well as a number of other NuGet packages. The solution builds fine on my development machine.
When I try to run NuGet restore on the TFS build server with NuGet 4.0.0 or 4.1.0, I get the following error:
Package (mypackagename) 1.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package (mypackagename) 1.0.0 supports:
- net35 (.NETFramework,Version=v3.5)
- netstandard2.0 (.NETStandard,Version=v2.0)
This error message is similar to that described in Nuget restore fails for ASP.NET Core 2.0 project on build server so I tried the solution suggested there, which is to use NuGet 4.3.0 or later. I've tried all released versions from 4.3.0 to 4.6.2, and this time I get the following error from NuGet restore:
2018-04-17T15:45:15.2611952Z Value cannot be null.
2018-04-17T15:45:15.2611952Z Parameter name: key
2018-04-17T15:45:15.2611952Z System.ArgumentNullException: Value cannot be null.
2018-04-17T15:45:15.2611952Z Parameter name: key
2018-04-17T15:45:15.2611952Z at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2018-04-17T15:45:15.2611952Z at NuGet.Commands.RestoreCommandProvidersCache.GetOrCreate(String globalPackagesPath, IReadOnlyList`1 fallbackPackagesPaths, IReadOnlyList`1 sources, SourceCacheContext cacheContext, ILogger log)
2018-04-17T15:45:15.2611952Z at NuGet.Commands.DependencyGraphSpecRequestProvider.Create(String projectNameToRestore, ExternalProjectReference project, HashSet`1 projectReferenceClosure, RestoreArgs restoreArgs, DependencyGraphSpec projectDgSpec)
2018-04-17T15:45:15.2611952Z at NuGet.Commands.DependencyGraphSpecRequestProvider.GetRequestsFromItems(RestoreArgs restoreContext, DependencyGraphSpec dgFile)
2018-04-17T15:45:15.2611952Z at NuGet.Commands.DependencyGraphSpecRequestProvider.CreateRequests(RestoreArgs restoreContext)
2018-04-17T15:45:15.2611952Z at NuGet.Commands.RestoreRunner.<CreatePreLoadedRequests>d__11.MoveNext()
2018-04-17T15:45:15.2611952Z --- End of stack trace from previous location where exception was thrown ---
Any suggestions as to how I can get this working?

I fixed this by setting "Clean = True" in the "Get Sources" task of my Team Build.
After doing this, I could use a recent version of NuGet (4.6.2), which no longer throws the ArgumentNullException above.
I suspect a bug in NuGet, where it gets confused by files left around from a previous build.

Related

Cake Addins install fail error during build

I am using net 4.8 framework. and cake version 0.38.2.
During build in Teamcity, it has to install addins cake.npm, cake.filehelpers. But following error happens
Could not find any assemblies compatible with .NETFramework,Version=v4.6.1.
Error: Failed to install addin 'Cake.Npm'.
When I use cake.npm version as 0.17.0 for cake 0.38.2, it generates two folders - cake.npm and cake.npm0.17.0. Only cake npm0.17.0 is required, because it has netstandard2.0 which can make build successful. But the other folder makes it fail
As discussed in https://github.com/cake-contrib/Cake.Npm/issues/140 Cake.Npm is not the culprit, here.
There is an additional (#load) reference in the project to Cake.Sitecore in version 1.0.3 which in contents/scripts/tasks.restore.cake contains the line
#addin "Cake.Npm"
This - without an explicit version being set - will always default to the newest version (currently 2.0.0, which is incompatible with Cake 0.38.2).
The current version of Cake.Sitecore (1.0.27) has that problem fixed.

Failed startup of context o.e.j.w.WebAppContext error after upgrade jetty version to 9.4.44

Current jetty version is 9.4.6, I tried to upgrade 9.4.44, I got the error. Could you please help me?
WebAppContext:554 -Failed startup of context o.e.j.w.WebAppContext#163f1cd{passwd-change,/passwd-change,file:///run/opt/corp/gsec/7.0.0/java-service/gsec-jetty-base/temp/jetty-gsec-2443-passwd-change.war-_passwd-change-any-6326268666909012254.dir/webapp/,UNAVAILABLE}{/passwd-change.war}
Caused by: java.lang.IllegalAccessError: tried to access method org.eclipse.jetty.server.handler.ContextHandler$StaticContext.createInstance(Ljava/lang/Class;)Ljava/lang/Object; from class jetty.webapp.StandardDescriptorProcessor
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.newListenerInstance(StandardDescriptorProcessor.java:1945) ~[apacheds-service-2.0.0-M24.jar:2.0.0-M24]
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1900) ~[apacheds-service-2.0.0-M24.jar:2.0.0-M24]
The jetty files in your apacheds-service-2.0.0-M24.jar needs to be upgraded as well.
List the contents of the apacheds-service-2.0.0-M24.jar file and you'll see classes in the org.eclipse.jetty. namespace.
Those are conflicting with your efforts to upgrade Jetty via the jetty-distribution zip.
I had a different setup that triggered a similar stacktrace: using cargo-maven2-plugin 16.1 in a spring 5 project, mvn cargo:run would fail because of a conflict with javafx.base-11.0.0-SNAPSHOT.jar files.
Upgrading to cargo-maven3-plugin 1.9.9 fixed the matter.
I'd encourage who ever uses cargo-maven2-plugin to migrate to cargo-maven3-plugin as the doc states:
Please be aware that the Maven 2 / Maven 3 plugin of Codehaus Cargo has been retired with our version 1.9.0 and has been superseded by a Maven 3 only plugin.

Could not load file or assembly System.Reflection.TypeExtensions

I got below exception while running xunit test projects which works under VS 2017 15.3
[2017/12/4 23:08:40 Error] [xUnit.net 00:00:00.0033291] xxx.Test: Catastrophic failure: System.TypeInitializationException: The type initializer for 'Xunit.DiaSession' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Xunit.DiaSession..cctor()
--- End of inner exception stack trace ---
at Xunit.DiaSession..ctor(String assemblyFileName)
at Xunit.DiaSessionWrapper..ctor(String assemblyFilename)
at Xunit.XunitFrontController..ctor(AppDomainSupport appDomainSupport, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.RunTestsInAssembly(IRunContext runContext, IFrameworkHandle frameworkHandle, LoggerHelper logger, IMessageSinkWithTypes reporterMessageHandler, AssemblyRunInfo runInfo)
My current VS 2017 version is 15.4.5.
I have tried the work around which has been provided previously, but none did not work. And I have try to downgrade my VS 2016 to 15.3, but I could not find the 15.3 package to install. I have tried to install xunit to latest version.
Any help would be appreciated.
Update:
Project Type:xUnit Test Project(.NET Core)
Target: net 461
It seems VS 2017 fail to load specific "xunit.runner.visualstudio", after checking VS2017 15.4.2 - Unable to run tests for projects targeting .NET Framework 4.6.x #1542 again, I deleted the "%TEMP%\VisualStudioTestExplorerExtensions", create a new Xunit project, change the nonworked.csproj xunit.runner.visualstudio from 2.2.0 to 2.3.1, it works now. Not sure why it did not work when I try it previous.
Hope it will help others.
You need to install System.Reflection.TypeExtensions using VS Package Manager using the following command:
Install-Package System.Reflection.TypeExtensions -Version 4.5.1
for more information please review the following link
System.Reflection.TypeExtensions

How to update .NETStandard in VS 2017?

When installing TweetSharp I get this error message:
Install-Package : Package TweetSharp 2.3.1 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package TweetSharp 2.3.1 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- sl4 (Silverlight,Version=v4.0)
- sl4-wp (Silverlight,Version=v4.0,Profile=WindowsPhone)
- sl4-wp71 (Silverlight,Version=v4.0,Profile=WindowsPhone71)
I have tried updating .NETStandard to the most recent release being 2.0 but that doesn't work.
I have also tried using the command 'nuget.exe locals -clear all' that also doesn't work.
How can I update netstandard1.4 to one supported by TweetSharp?
Thank you.

Xamarin linker error with AWSSDK

I have a Xamarin forms mobile project (Android and iOS).
When I try to install the AWSSDK.S3 to access Amazon services, I get the following linker error when trying to build iOS:
Failed to resolve "System.Void Amazon.Runtime.Internal.Util.AESEncryptionPutObjectStream::.ctor(System.IO.Stream,System.Byte[],System.Byte[])" reference from "AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604"
..Android build has a similar error.
I have the following libraries installed:
AWSSDK.S3 v3.1.1.1
AWSSDK.Core v3.3.4
AWSSDK.SecurityToken v3.3.0.2
AWSSDK.CognitolIdenity v3.3.0.2
AWSSDK.CognitoIdentityProvider v3.3.1.2
PCLCrypto v2.0.147
PCLStorage v1.0.2
the only code in my project is:
var amazonClient = new AmazonS3Client();
Any ideas?
possible (bad) workaround that seems to work:
change in Linker Options/Linker behavior:
to: Don't link
instead of: Link SDK Assemblies only
The answer turns out to be found here:
Xamarin Forms IOS Failed to load assembly System.Net.Http.Primitive
even though its a different assembly error, the fix is the same:
update all the AWS.Core to the latest version: v3.3.6 in my case
install Microsoft.Bcl.Build v1.0.21
install Microsoft.Net.Http v2.2.29
Rolling back to AWSSDK.S3 V3.1.10 worked for me, done using the NuGet manager in Visual Studio. =)