Installing Glass.Mapper - sitecore

What packages do I need to install in order to setup Glass.Mapper for Sitecore 8.1 with VS2013 and MVC 5.2.3.0 using NuGet? I already have Castle.Windsor.
I tried Glass.Mapper.Sc on its own, tried BoC.Glass.Mapper.Sc.Mvc-5 on its own, and tried both of them together I always get run time errors when opening the content editor in Sitecore UI:
Method not found: '!!0 Glass.Mapper.Context.GetTypeConfiguration(System.Type, Boolean, Boolean)'.
Plus which of them do I need for other solution projects?
Update1:
I had to go the sitecore bin folder to remove all Glass.Mapper related DLLs (from previous package installation attempts) and then installed Glass.Mapper.Sc again. Now I can open the Content Editor, however I got an error while publishing:
Could not resolve type name: Glass.Mapper.Sc.ContentSearch.LuceneProvider.GlassDocumentMapperObjectFactory, Glass.Mapper.Sc.ContentSearch.LuceneProvider (method: Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)).
So I installed Glass.Mapper.Sc.ContentSearch.LuceneProvider but then I got another error related to Glass.Mapper's version of Castle.Windsor, so I installed Glass.Mapper.Sc.CastleWindsor.
Now when I click on publish, I get the following:
Could not resolve type name: Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc (method: Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert)).

It's worth going to the glass website and viewing tutorials. To quote the linked page:
Before install Glass.Mapper.Sc you need to reference the following
assemblies in your project:
Sitecore.Kernel.dll
System.Web.Mvc.dll
Both these files can be found in the bin folder of your Sitecore solution. These assemblies are used
to determine which version of the Glass.Mapper assemblies should be
referenced.
Once you have added the references above to your project you can
download Glass.Mapper.Sc from Nuget. Open the Nuget Package Manager
and search for Glass.Mapper.Sc:
Glass.Mapper.Sc V4 Nuget Package in Package Manager
The Nuget package will add references to the Glass.Mapper.dll,
Glass.Mapper.Sc.dll, Glass.Mapper.Sc.Mvc.dll and Castle.Core.dll:
V4 Reference add to Project
The Nuget package also install some additional CS files and config
files:
Glass.Mapper.Sc V4 Files added to Project
You are now ready to start working with Glass.Mapper. Tutorial 2 will
show you how to create your first model.

We are using on same environment like you GlassMapper 4.0.5.54.
You don't need to use Boc.Glass.Mapper.Sc.Mvc
On packages.config we have
<package id="Glass.Mapper.Sc" version="4.0.5.54" targetFramework="net45" />
To install a specif version you can use command line:
Install-Package CGlass.Mapper.Sc -Version 4.0.5.54

I Resolved it by commenting out
<handler type="Glass.Mapper.Sc.Events.PublishEnd.GlassCacheClear, Glass.Mapper.Sc" method="ClearCache">;
in lass.Mapper.Sc.config file.
Good luck.

Related

Visual Studio 2017 Nuget Install Package Builds Project Instead of Installing / Uninstalling Packages

When importing existing library projects into an existing solution (after I copied them locally from somewhere else), when I try to install or uninstall a Nuget package through the package manager, it justs builds my solution showing me all of the errors I have because the package is not installed. It does nto try to install or uninstall the package. Why is it building my project instead of just installing / uninstalling the bloody package?
Why is it building my project instead of just installing /
uninstalling the bloody package?
It's not default behavior of VS IDE itself.
As for VS2017, if we install a normal package using Package Manager UI, VS will check the compatibility between the package to consume and the current project. If they're compatible, the package will be installed successfully, if not, VS will throw nuget error like NU1202 or others in ErrorList window.
But I'm sure for VS2017, installing/uninstalling won't call a build.
Possible causes of the issue and corresponding suggestions:
1.This behavior results from one third-party extension.
Reset all VS settings => disable all the third-party extensions => restart VS to check if the issue persists. If after the check you find this issue results from one extension, you need to make sure if the extension provides one option to turn on/off the auto-build. Or you may need to disable/uninstall the extension temporarily and contact the author of the extension to post the issue.
You may get more details for trouble-shooting from this similar issue.
2.Custom script(.ps1,.targets) from one specific nuget package causes this.
The authors can place powershell script and PackageID.targets in .nupkg when generating packages. Some of these scrips will execute when we install the package, others will execute when we uninstall the package. See similar issue here.
You can create a new simple console project TestProject in TestProject solution. Then right-click solution=>add=>Existing project to import a new external project. Now let's install the Newtonsoft.Json package to check if the issue disappears. If the issue disappears in new project with Newtonsoft.Json package. I think it indicates one special package you try to install/uninstall may cause the issue.
Hope all above helps and feel free to let me know if there's any update.

Issue with updating NuGet packages (VS2017)

Visual Studio 2017 - Saying "Package restore failed" while updating the NuGet packages as following:
Issue with updating NuGet packages (VS2017)
To resolve this issue, first, you should make sure your Target Framework that is used to compile your android application, Use Latest Platform (Android 8.1 (Oreo)).
Check source: Understanding Android API Levels
Second, if you confirm your Target Framework is Android 8.1 (Oreo), then Select all packages checkbox, and click Update button:
After that, all nuget packages can be updated to latest version.
The reason for this issue:
To find the reason for this issue, change the MSBuild build log to Detailed, Tools->Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity:Detailed.
When you update one of those default nuget packages, in the output you will get following dependencies conflict errors:
NU1107: Version conflict detected for Xamarin.Android.Support.Compat.
Reference the package directly from the project to resolve this issue.
App1.Android -> Xamarin.Android.Support.Design 27.0.2 ->
c (= 27.0.2) App1.Android ->
Xamarin.Android.Support.v7.AppCompat 25.4.0.2 ->
Xamarin.Android.Support.Compat (= 25.4.0.2).
That means when you update the default package Xamarin.Android.Support.Design to 27.0.2, one of its dependencies, Xamarin.Android.Support.Compat also need to be updated to 27.0.2. However, other nuget package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 still reference the Xamarin.Android.Support.Compat with the old version 25.4.0.2. So you will get that error.
To resolve this error, you should update all default package at once instead of one of them.

What do Yellow Warning Triangles mean on Dependencies in Visual Studio 2017?

I have just converted my PCL library to a new .Net Standard library and I have some Yellow Warning triangles on my Dependencies shown below:
During the conversion it brought all nuget packages across including dependencies so it could be dulicates.
How do I find out what the Yellow warning triangles represent?
EDIT
Build Logs:
To prevent NuGet from restoring packages during build, open the Visual
Studio Options dialog, click on the Package Manager node and uncheck
'Allow NuGet to download missing packages during build.' NU1605:
Detected package downgrade: NUnit from 3.8.1 to 2.6.4. Reference the
package directly from the project to select a different version.
MyProj.UI.Tests -> MyProj.Core.Tests -> NUnit (>= 3.8.1)
MyProj.UI.Tests -> NUnit (>= 2.6.4) NU1605: Detected package
downgrade: NUnit from 3.8.1 to 2.6.4. Reference the package directly
from the project to select a different version. MyProj.UI.Tests.iOS
-> MyProj.UI.Tests -> MyProj.Core.Tests -> NUnit (>= 3.8.1) MyProj.UI.Tests.iOS -> NUnit (>= 2.6.4) NU1605: Detected package
downgrade: NUnit from 3.8.1 to 2.6.4. Reference the package directly
from the project to select a different version.
MyProj.UI.Tests.Android -> MyProj.UI.Tests -> MyProj.Core.Tests ->
NUnit (>= 3.8.1) MyProj.UI.Tests.Android -> NUnit (>= 2.6.4)
As trite as it sounds, try rebuilding then restarting VS - and get on with your day :)
run dotnet restore before you do any complicated manipulation, you are going to be provided with a lot more info than in the error window or solution explorer.
You can run this command in the Package Manager Console:
Tools > NuGet Package Manager > Package Manager Console
If you have the warning icon but no warnings and nothing appears to actually be wrong, right click the project > Unload Project > right click the project again > Reload Project. The icon appeared for a moment and then was cleared for me in Visual Studio 2019. This avoids a full Visual Studio restart.
In the build Log I happened to notice this:
C:\Program
Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets(199,5):
warning : A PackageReference for 'NETStandard.Library' was included in
your project. This package is implicitly referenced by the .NET SDK
and you do not typically need to reference it from your project. For
more information, see https://aka.ms/sdkimplicitrefs
I therefore went and uninstalled all packages that were listed as dependencies for the .Net Standard nuget listed here:
.NETStandard 1.1
Microsoft.NETCore.Platforms (>= 1.1.0)
System.Collections (>= 4.3.0)
System.Collections.Concurrent (>= 4.3.0)
System.Diagnostics.Debug (>=> 4.3.0)
System.Diagnostics.Tools (>= 4.3.0)
System.Diagnostics.Tracing (>= 4.3.0)
System.Globalization (>= 4.3.0)
System.IO (>= 4.3.0)
System.IO.Compression (>= 4.3.0)
System.Linq (>= 4.3.0)
System.Linq.Expressions (>= 4.3.0)
System.Net.Http (>= 4.3.2)
System.Net.Primitives (>= 4.3.0)
System.ObjectModel (>= 4.3.0)
System.Reflection (>= 4.3.0)
System.Reflection.Extensions (>= 4.3.0)
System.Reflection.Primitives (>= 4.3.0)
System.Resources.ResourceManager (>= 4.3.0)
System.Runtime (>= 4.3.0)
System.Runtime.Extensions (>= 4.3.0)
System.Runtime.InteropServices (>= 4.3.0)
System.Runtime.InteropServices.RuntimeInformation (>=> 4.3.0)
System.Runtime.Numerics (>= 4.3.0)
System.Text.Encoding (>= 4.3.0)
System.Text.Encoding.Extensions (>= 4.3.0)
System.Text.RegularExpressions (>= 4.3.0)
System.Threading (>= 4.3.0)
System.Threading.Tasks (>= 4.3.0)
System.Xml.ReaderWriter (>= 4.3.0)
System.Xml.XDocument (>= 4.3.0)
And the yellow warnings disappeared.
From here: https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-standard-2-0/
I have also found you can use the NoWarn property like below:
<ItemGroup>
<PackageReference Include="Huitian.PowerCollections" Version="1.0.0" NoWarn="NU1701" />
</ItemGroup>
The yellow triangle means that the package physical file(s) is gone and no longer available on the Hard Drive.
This usually happens when issuing a get latest version request on source control in TFS, especially when using a new machine, and you want to get your project code from the TFS server.
It can also be caused by low quality internet connection which almost always will result in data loss, or corrupted downloaded files.
If the problem is missing a couple of packages, you can modify the packages.config file and remove these packages from the packages.config and re-install the missing packages via nuget packages manager.
But if the problem is missing more than a few packages, the best and fast way I use to retrieve missing packages is by:
Opening a new instance of visual studio
Create a new project solution with same project type like the one with missing packages (Example: ASP.Net MVC with Individual User Account)
Update the packages of the new project to the latest to match the packages versions of the previous project solution
Open the file explorer and navigate to packages folder in the new solution that you created
Copy all contents of folder Packages by selecting all, Note do NOT copy the Packages folder itself only the contents inside the folder
Paste that in your previous solution ( solution with the missing packages), in the Packages folder with overwrite existing items.
Go to your packages folder in the solution explorer and expand it, then click the refresh button to see that many of missing packages are now showing without yellow triangle
Lastly you will end up with a couple of missing packages, that are not included by default when you create new solution, you need to remove them from your packages.config file (the file which nuget package managers) reads to determine installed packages, and install those as new using the nuget package manager.
Note such problems related to missing files from projects are always hard to fix, and depends on developer experience, so don't expect an easy solution for this one.
On the cause of the error,Microsoft says it is a bug, but it can happen on any version of Visual Studio.
For any new person with this issue: try this and you will remember me :D
Go to: Tools > NuGet Administrator > Configurations and verify that you have Allow nuget... and automatically check... checked.
After that, the only thing you have to do is click on the button "Clear All NuGet Cache(s)"!
That's it. You don't have to edit anything manually; that can be dangerous, believe me, I used to need to do some of the steps described here a lot of the time.
If you want to try the official Microsoft solution for this issue, you could check it here: https://learn.microsoft.com/es-es/nuget/consume-packages/package-restore#restore-packages-automatically-using-visual-studio
But just cleaning the cache solved all the problems for me.
I just had this issue in VS2019 version 16.8.3 when renaming a .NET Core 3.1 project. Directly after renaming the project the yellow triangles appeared. Rebuild, clean, etc. nothing worked. Closing and reopening the solution solved it for me.
Oddly enough, my .Net Core 3 project needed me to simply click "Load project dependencies" from the context of the project, then the warning icon disappeared.
Helpful screenshot:
The yellow exclamation sign is usually because of missing references or unsupported dll. If you clone a repository then there are chances that many of the nugget packages will show yellow exclamation. If you have verified the project version and still, the problem exists you can try the below solution.
In the package manager console, select the project in which you are facing this problem and then type the following command.
Update-Package -Reinstall
This will force reinstall all the packages. This command will not update the version of NuGet packages, it will simply force reinstall them.
This solution worked in my case. I am using VS2019. Hope this will help others as well.
-unload project
-load project
This worked for me.
It will help if you
remove bin folder and obj folder
clean the project
Better also to remove the cached packages from C:\Users\{user}\.nuget\packages
Then restore the packages. that work for me.
dotnet restore
If I try to uninstall Microsoft.NETCore.Platforms as stated in the marked answer I get the following error:
Unable to uninstall 'Microsoft.NETCore.Platforms.1.1.0' because 'NETStandard.Library.2.0.3' depends on it.
I uninstalled the other packages, but I still get the NETSDK1023 error:
A PackageReference for 'NETStandard.Library' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs
Now I edited my .csproj and deleted the following part
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
as stated in https://aka.ms/sdkimplicitrefs under Recommendations:
When targeting .NET Core or .NET Standard, never have an explicit reference to the Microsoft.NETCore.App or NETStandard.Library metapackages via a <PackageReference> item in your project file.
Now the warning is gone!
I faced this error when I clone the project. the main reason was the Nuget packages couldn't restore and I find a solution by making nuget.org only active resource.
Make sure you select Nuget.org as only active resource.
Hope it helps
I had the same issue , after banging my head 2 days I found that this is because
Long path was not allowed
For example two class libraries in my project had name length > or = 40
So they were not loading dependency of netstandard2.0
If you have the same case , You need to first update long path limit from registry and set its value to 1
see https://www.thewindowsclub.com/how-to-enable-or-disable-win32-long-paths-in-windows-11-10
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Like I said in another post, about the same issue, this is only for documentation... I know that this was ready to solve it, and one of my answers was ready to say something about that, but, maybe some of you present the same error and none of this solution listed here solves the problem... I don't know why this problem comes with the global installation of .net 6, but, if you present this issue again, you need to go to
C:\Users\YourUsername.nuget
And delete all the content, don't be afraid, that's a cache generator than will be created again if is need it.
I just updated Visual studio to 16.4.4 and the issue was resolved.
The reference is fixed and no more yellow triangle.
Thanks.
I had the triangles on referenced projects dependencies. I had added reference of
System.Drawing.dll
.There was also warning in error list box .
Removing it solved the problem for me.
You know ,according to warning in error list System.Drawing.dll has forwarded to System.Drawing.Common
and you need to install it through Manage NuGet Packages .
Now it works properly.
Go to your project/solution directory and execute:
dotnet restore
Then you are done!
I just Mapped my local folders to the tfs code branch and had these issues,
I had to look into the project Build order, clean them one by one in order and build them after cleaning.(Or you can try cleaning the whole solution and build it again)
You can look into the project build order by Select the Solution > Project (From Top) > Build Order
I had taht issue, when changing the output directory:
<BaseOutputPath>$(SolutionDir)</BaseOutputPath>
As soon as i deleted that property, everything worked fine! (VS 2022 v17.0 btw)
None of the above worked for me. I had one project in the solution with warning triangles on the dependencies to other projects in the solution which caused lots of red errors in VS. However, it would build, run and debug just fine. I finally unloaded the project with a right click on the project name in the solution tree, and then reloaded the project and all is happy now. Thanks Visual Studio, smh. I am using VS 2019 16.7.1
Right click on Solution and Rebuild Solution.
It worked for me.
I had the triangles on referenced projects dependencies. I just removed and added the dependencies to remove the triangle.
I am posting this answer just because no other solutions presented here helped me.

Package X is not compatible with netstandard2.0

I created a .NET Standard v2.0 project in Visual Studio 2017 v15.3.1 and I'm unable to install "Microsoft.EntityFrameworkCore 2.0.0" package in it (by Nuget 4.3). Previously the .NET SDK and Runtime, both 2.0.0, were installed.
The errors I get follow this pattern:
"Package X is not compatible with netstandard2.0 (.NETStandard,Version=v2.0)." (i.e. System.Reflection.TypeExtensions 4.1.0).
What could it be causing these errors?
EDIT: I'll show the exact warnings and errors with an example (there are too many).
Restoring packages for [.csproj path]...
Warning:
Package "System.Collections 4.3.0" was restored using ".NETFramework,Version=v4.6.1" the project target framework ".NETStandard,Version=v2.0". This may cause compatibility problems.
...
Error:
Package Remotion.Linq 2.1.1 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Remotion.Linq 2.1.1 supports:
net35 (.NETFramework,Version=v3.5)
net40 (.NETFramework,Version=v4.0)
net45 (.NETFramework,Version=v4.5)
netstandard1.0 (.NETStandard,Version=v1.0)
portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
...
Error restoring package. Reverting package changes for 'ClassLibrary1'.
Time elapsed: 00:00:02.4689637
========== Ended ==========
Clicking the "Clear all Nuget Caches" will resolve issue.
Issue solved installing, independently, newer versions for each of the packages' dependencies which were showing error, so that the big package "Microsoft.EntityFrameworkCore 2.0.0" gets installed at last.
Hope it helps.
Edited: It happened to me another time and tried a faster solution. The key was deleting Nuget's cache from the packages' manager configuration.

32feet: could not install with nuget

I'm trying to install this library in an existing c++ project with NuGet, but the installation stops and give me the following message:
Could not install package '32feet.NET 3.5.0.0'. You are trying to install this package into a project that targets 'Native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
What does this mean?
Looks like NuGet currently doesn't support that:
http://nuget.codeplex.com/workitem/3665
https://nuget.codeplex.com/workitem/3530