Nuget SDK missing when Scaffolding a class Using Ardalis clean architecture template - nuget

Hi I trying Ardalis Clean Architecture.
Running VS 2022 and dotnet 6.
I am trying to scaffold a class and get the following error in the code generator phase:
"Scaffolding failed.
SDK Resolver Failure: "The NuGet-based SDK resolver failed to run because NuGet assemblies could not be located. Check your installation of MSBuild or set the environment variable "MSBUILD_NUGET_PATH" to the folder that contains the required NuGet assemblies. System.IO.FileLoadException: Could not load file or assembly 'NuGet.Versioning, Version=6.0.0.278, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)To see more information, enable tracing by setting environment variable 'codegen_trace' = 1.
File name: 'NuGet.Versioning, Version=6.0.0.278, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Versioning, Version=6.0.0.280, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.NuGetAbstraction.TryParseNuGetVersion(String version, Object& parsed)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.TryGetNuGetVersionForSdk(String id, String version, SdkResolverContext context, Object& parsedVersion)
at Microsoft.Build.NuGetSdkResolver.NuGetSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)" C:\Workspace\VSProjects\CleanArchitecture\xxx..."
Any one have a clue what is missing?

Related

Azure Devops Build pipeline NuGet pack fails (.net core 5)

As inuitive and handy setting up build pipelines is, I cannot figure out how to get a nuget package created after building. I am not using .yml.
Project is .Net Core 5.
This is the log:
System.IO.IOException: The process cannot access the file 'D:\a\1\s\Package\SomeCompanyPackages.0.0.1.nupkg' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
Id: SomeCompanyPackages
at System.IO.File.InternalDelete(String path, Boolean checkHost)
Version: 0.0.1
at NuGet.Commands.PackCommandRunner.BuildPackage(PackageBuilder builder, String outputPath, Boolean symbolsPackage)
Authors: VssAdministrator
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
Description: Description
at NuGet.CommandLine.PackCommand.ExecuteCommand()
Dependencies:
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
Added file '[Content_Types].xml'.
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
Added file '_rels/.rels'.
Added file 'SomeCompanyPackages.nuspec'.
Added file 'lib/net5.0/SomeCompanyPackages.dll'.
Added file 'package/services/metadata/core-properties/d9f19903a89841ee8740535a9eba2337.psmdcp'.
##[error]The nuget command failed with exit code(1) and error(Error NU5115: Description was not specified. Using 'Description'.
Error NU5115: Author was not specified. Using 'VssAdministrator'.
Error NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
- Add a dependency group for net5.0 to the nuspec
The process cannot access the file 'D:\a\1\s\Package\SomeCompanyPackages.0.0.1.nupkg' because it is being used by another process.
System.IO.IOException: The process cannot access the file 'D:\a\1\s\Package\SomeCompanyPackages.0.0.1.nupkg' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at NuGet.Commands.PackCommandRunner.BuildPackage(PackageBuilder builder, String outputPath, Boolean symbolsPackage)
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args))
##[error]An error occurred while trying to pack the files.
Finishing: NuGet pack
UPDATE:
just found out that there is another (newer) way to pack nu get packages.
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
Unfortunately this seems to be only available for yml config.
How can I add this to my configuration? There is no .NET Core CLI task available in task library for agent.
with respect to comment by D.J.
One solution is to add not one but two additional taks of type .NET Core
pack
push
Hope this helps newbies like me to get it running without spending hours of reading documentations that don't cover this after all.

Unity for UWP - Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Windows.Foundation.UniversalApiContract

I am using Unity 5.6.0f3 and Visual Studio Community 2017, version 15.3.2.
I have exported a project for UWP, Unity editor has created a solution for UWP which should be opened with Visual Studio.
When building this project in Visual Studio, regardless whether for x64 or x32 configuration, I get the following exception:
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Windows.Foundation.UniversalApiContract, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.TypeReference.Resolve()
at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
at Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
at Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypeDefs()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__1_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition, ReaderParameters readerParameters)
at usw.Weaver.Weave()
at usw.Program.RunProgram(ConversionOptions options)
at usw.Program.Main(String[] args)
Here are my references in the project:
What am I missing?

System.IO.FileNotFoundException Could not load assembly System.Drawing

I meet this error in a Xamarin.forms project using WebView and local html base url:
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't
exist in the Mono for Android profile? Nom de fichier :
'System.Drawing.dll' à
Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
reference, ReaderParameters parameters) à
Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1
assemblies, AssemblyDefinition assembly, Boolean topLevel) à
Xamarin.Android.Tasks.ResolveAssemblies.Execute() Almicantarat.Droid
I read that:
System.IO.FileNotFoundException: Could not load assembly System.Web in Mono for Android
but I don't know which client's source code I should compile.
I read that:
Could not load file or assembly 'System.Drawing, Version=4.0.0.0
but in my project, there is no reference to System.Drawing !!
See my references:
my android project references
Solved:
-> Close the solution
-> Delete all contents of the Packages folder (all the DLL's referenced through Nuget)
-> Restart the solution
-> Build (this will cause Nuget to get all DLL's again based on the packages.config)

Must I rebuild Nunit 2.6.2 to use it with .net 4.0?

When I try to run some tests with:
nunit-console.exe <mydll> /framework:net-4.0
I am rewarded with:
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'nunit-console-runner, Version=2.6.2.12296,
Culture=neutral, PublicKeyToke n=96d09a1eb7f44a77' or one of its
dependencies. The system cannot find the file specified. File name:
'nunit-console-runner, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at
NUnit.ConsoleRunner.Class1.Main(String[] args)
There is no file named nunit-console-runner anywhere.
When I leave off the /framework, all is well. However, I need the /framework as my goal is to debug as mixed-mode test failure on a 64-bit system.

Why is my project's assembly missing from the package when I debug?

I've got a SharePoint project that I've been debugging for some time without problems.
Today I added a feature receiver to the project's only feature. I've not yet changed anything about the empty receiver class that Visual Studio adds by default.
The "Package" command now generates a package which includes my project's DLL file (as you'd expect -- adding a feature receiver shouldn't change anything about this).
However, when I debug, the generated package does not include my project's DLL file, and the deployment effort fails with the following error:
Error occurred in deployment step 'Add Solution': Failed to load
receiver assembly "ABC, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=2377fad544a7c307" for feature "ABC_XYZ Feature" (ID:
dca34989-a2f2-413b-b5c4-958e0bbb84ef).:
System.IO.FileNotFoundException: Could not load file or assembly 'ABC,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=2377fad544a7c307' or
one of its dependencies. The system cannot find the file specified.
File name: 'ABC, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=2377fad544a7c307' at
System.Reflection.Assembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, Assembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection) at
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection) at System.Reflection.Assembly.InternalLoad(String
assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark,
Boolean forIntrospection) at System.Reflection.Assembly.Load(String
assemblyString) at
Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Removing the feature receiver allows me to again debug without issue, but the problem returns as soon as I re-add the feature receiver.
I've tried cleaning and rebuilding, and then debugging, but the error won't go away unless/until I remove the feature receiver.
Why does my project's assembly get included in the package when I use the "Package" command, but not when I use the "Start Debugging" command, and what about adding the feature receiver causes this to happen?
The accepted answer to this question did not work for me.
The following did work:
...simply changing out the project’s strong key assembly worked in this particular case. If you haven’t had to change this before, it is under the properties of the project -> Signing. Under ‘Choose a strong name key file’, select New. The password is optional.
Thanks to this blog post: Farm Solution Deployment Problems
I don't know what caused it to happen, but the problem went away when I manually cleared my obj and bin directories. Here are the steps I followed for getting from the state cited in the question to successful debugging w/ a feature receiver:
Remove feature receiver
Clean solution
Close Visual Studio
Delete SharePoint project's obj folder in Windows Explorer
Delete SharePoint project's bin folder in Windows Explorer
Open Visual Studio and re-add feature receiver
Start Debugging
I tried to go in Visual Studio for right click on solution - properties.
Under application, assembly information and then I raised Assembly and File version by "minimum 1" (from 1.0.0.0 to 1.0.0.1).
Then it was possible to deploy (and mainly activate feature) solution "into WebApplication"