I'm trying to hack a MVC 3 project template to automatically install elmah via nuget.
Since MVC 3 Tools update, MVC3 project templates contains this section :
<WizardData>
<packages>
<package id="jQuery" version="1.5.1" />
<package id="jQuery.vsdoc" version="1.5.1" />
<package id="jQuery.Validation" version="1.8.0" />
<package id="jQuery.UI.Combined" version="1.8.11" />
<package id="EntityFramework" version="4.1.10331.0" />
<package id="Modernizr" version="1.7" />
</packages>
</WizardData>
So i've tried to add elmah package like this :
<WizardData>
<packages>
...
<package id="elmah" version="1.2.0.1" />
</packages>
</WizardData>
I've also downloaded and added elmah.1.2.0.1.nupkg file in
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Packages
folder along with default packages (jQuery.1.5.1.nupkg, EntityFramework.4.1.10331.0.nupkg etc...)
Unfortunately, i keep having this error when i create a new MVC3 project :
(source: free.fr)
Does anyone knows how to solve this error?
At least is it something feasible with this version of mvc3 tools ?
I just blogged about how to do this: http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
This walks through creating and registering a custom project template.
Related
So I migrated from nuget packages.config to PackageReference and found out there were some compatibility issues. I reverted the project to its working state (before the PackageReference) and now my project is not compiling.
I get the following error:
Severity Code Description Project File Line Suppression State
Error The package EntityFramework with version 6.2.0 could not be found in C:\Users\user.nuget\packages. Run a NuGet package restore to download the package. DbManager
This happened to multiple packages. It seems that Nuget is searching for packages in the user.net\package directory for some reason. Originally, there was a folder within the project that contained all the packages.
I forced the global path to be at the folder within the project by editing the NuGet.Config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="C:\Projects\App\App Source\packages\" />
<add key="globalPackagesFolder" value="C:\Projects\App\App Source\packages\" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
I don't know why Nuget keeps looking for packages at that location. It should be looking at the packages folder within the project.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="EntityFramework6.Npgsql" version="3.1.1" targetFramework="net46" />
<package id="Npgsql" version="3.2.7" targetFramework="net46" />
<package id="System.Threading.Tasks.Extensions" version="4.3.0" targetFramework="net46" />
<package id="Z.EntityFramework.Plus.EF6" version="1.7.17" targetFramework="net46" />
</packages>
All of these packages in packages.config are not being found. This problem started happening when I tried PackageReference.
Is there any way to reset Nuget's settings? I would appreciate any guidance in solving this problem.
TLDR; This is caused by latent copies of the new project.assets.json file being left in your /obj/ folders. These can be safely deleted.
You can run this Powershell (at your own risk) in your root solution folder as a quick way to purge these files:
ls project.assets.json -Recurse | foreach {rm $_}
project.assets.json is generated for projects using PackageReference to cache the Nuget dependency graph for your project. It seems to confuse Visual Studio/Nuget if it's left there even if your project is using (or reverted back to using) packages.config
This can happen in Visual Studio 2019 as well, if you try PackageReference and then revert back to packages.config (or even if you switch between Git branches with one Nuget restore method versus the other).
Further Info
More info on project.assets.json here:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x
I am working on Xamarin.Forms project for my company and we plan to release our app on IOS and Android (Using Visual Studio Community Edition on Macbook pro). So far everything seemed to be OK. And then suddenly I cannot build debug or release on Android project. I am getting this error:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Compat.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:220
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:170
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <593a6fd557984367bb21e275d0fa0659>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <593a6fd557984367bb21e275d0fa0659>:0
I am pretty sure I haven't changed any source files, it was building up until now..
The only App Compat I use is "Xamarin.Android.Support.v7.Compat".
The things I tried:
Removing all packages and adding them again.
Creating fresh Xamarin.Forms project and pulling code from git - same error
Installing Xamarin.Android.Support.Compat - Error I got:
You are trying to install this package into a project that targets
'MonoAndroid,Version=v6.0', but the package does not contain any
assembly references or content files that are compatible with that
framework.
Made sure my target framework is same as target version (Use API 23) and my minimum target version is API 19.
Deleting Bin and Obj directories, restarting solution and building again.
I am using Xamarin.Forms 2.4.0.38779. I tried removing all packages and updating for the newest Forms - still got same error.
This is packages.config for Droid project:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="modernhttpclient" version="2.4.2"
targetFramework="monoandroid60" />
<package id="Plugin.PushNotification" version="1.1.2"
targetFramework="monoandroid60" />
<package id="Rg.Plugins.Popup" version="1.0.4"
targetFramework="monoandroid60" />
<package id="Xam.Plugin.DeviceInfo" version="3.0.2"
targetFramework="monoandroid60" />
<package id="Xam.Plugins.Settings" version="3.1.1"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable"
version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable"
version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Forms" version="2.4.0.38779"
targetFramework="monoandroid60" />
</packages>
I will provide any logs, if needed.
So after enabling detailed build output I found the issue!
Xamarin is really bad with it's error description, and by investigating into Build Log I found out that this missing dll was required by Plugin.PushNotification NuGet package I use for both iOS and Android. After removing all references to this package from Android project, it started building again!
I have been working on Xamarin projects on my Macbook Pro for the better part of this year to know these type of issues.
This would usually happen if you copy a Xamarin project running on OSX to Windows or visa versa.
The solution is always the same. List down all the used packages in your project. Do a whole removal of the packages and reinstall them again cleanly with their specified version numbers.
I've just inherited an old Xamarin Forms application and I'm trying to upgrade all the packages. App was initially running fine, but since upgrading to the latest version of all packages, I'm now getting a crash calling Xamarin.Forms.Forms.Init(this, bundle);:
Could not load type 'Xamarin.Forms.PreserveAttribute' from assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
Here's my packages.config file contents:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExifLib.PCL" version="1.0.1" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="MonoAndroid50" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="MonoAndroid50" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms" version="2.3.0.38-pre2" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms.Labs" version="1.2.1-pre2" targetFramework="MonoAndroid44" />
<package id="Xamarin.Forms.Maps" version="2.2.0.31" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Maps" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.Insights" version="1.12.3" targetFramework="MonoAndroid50" />
</packages>
I closed Xamarin Studio and cleared obj and bin folders and started Xamarin Studio again and everything worked fine
I had the same issue but I noticed that the Xamarin.Forms package had an update. I updated this package and the issue went away.
I had the same message from a freshly created default Xamarin Forms app (Native, with Portable Class Library) after adding a new Form to the PCL (via the "Add New Item" context menu in Visual Studio and selecting Xamarin.Forms/Content Page).
It turned out that the packages.config in the PCL specified a different version for Xamarin.Forms than the one in UWP project.json file.
Making both projects use the same version of Xamarin.Forms by editing the packages.config fixed the problem.
The path of project must have not '#' character
In my case i had downgraded the Xamarin version from 3.x to 2.5 for all the projects. But somehow the .Net Standard project was not downgraded.
Started working after downgrading the .net standard project.
I'm developing a new WPF project with C#, Visual Studio 2015 Community, .NET Framework 4.6.1 and Enterprise Library (latest version).
I'm trying to use Enterprise Library Console to add a Logging Exception Handler:
Do I have to do something to show Logging Exception handler option?
Here is my package.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net461" />
<package id="EnterpriseLibrary.ExceptionHandling" version="6.0.1304.0" targetFramework="net461" />
<package id="EnterpriseLibrary.Logging" version="6.0.1304.0" targetFramework="net461" />
</packages>
You need to install the NuGet package for EnterpriseLibrary.ExceptionHandling.Logging. That package is what provides the connection between the Exception Handling Block and the Logging Block (it provides the ExceptionHandler that uses the Logging block).
I removed Microsoft.ApplicationInsights from my Windows Store (8.1) app, but it keeps coming back (with a yellow warning glyph) beneath "References". It doesn't seem to really cause much mayhem, but I'd still like to completely get rid of it out of this project.
When I remove the reference, it goes away, but then comes back later. Is it because of what remains behind in packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Callisto" version="1.4.0" targetFramework="win81" />
<package id="ExifLib" version="1.6.3.0" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights" version="0.10.0-build17704" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights.RuntimeTelemetry" version="0.10.0-build17704" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights.WindowsStore" version="0.10.0-build17704" targetFramework="win81" />
<package id="sqlite-net" version="1.0.8" targetFramework="win81" />
</packages>
?
If so, is it safe to strip the three references to Microsoft.ApplicationInsights directly out of packages.config?
EDIT:
I removed the ApplicationInsights reference, stripped out the three references to ApplicationInsights from package.config, built the project (fine), closed the project, re-opened the project, and the dad-burned ApplicationInsight reference was back again (packages.config remained pristine).