cannot use add-Migration in .net core 2.1 project using visual studio for mac - asp.net-core

I am using Visual Studio for Mac and have .NET Core 2.1 project. I have an issue when using any migration command like "Add-Migration", namely the following error occurs:
**Add-Migration : The term ‘Add-Migration’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Add-Migration DBUpdates -Context applicationdbcontext
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException**
Any clue what the cause of this could be?

This error indicates that one package is missing.
Install package Microsoft.EntityFrameworkCore.Tools from nuget. Then reopen the visual studio.

You might be missing the nuget package, if thats not the case also double check you have the powershell interface in Visual Studio pointing at the correct project (You want the one where your DbContext object exists and is defined)

Related

Intellij IDEA Terminal issue

I am using Intellij IDEA for Python. There is a terminal inside the IDE, on which I tried to run a command for making text file. I ran the command:
type null > HelloWorld.txt
It showed an error, but it worked correctly. The text file was created but it showed the following error (This problem is only in Intellij IDEA, it works correctly on command prompt):
type : Cannot find path 'D:\KARTEEK\document space\school\Class-7\My Python Projects\Kivy GUI\null' because it does not exist.
At line:1 char:1
+ type null > HelloWorld.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\KARTEEK\docu...s\Kivy GUI\null:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
But the file was made. Please help

ASP.NET Core error on building with NSwag Error MSB3073

When I build the application, I get the following error message
The command "dotnet "C:\Users\Adminuser\.nuget\packages\nswag.msbuild\13.0.6\build\../tools/NetCore22/dotnet-nswag.dll" run /variables:Configuration=Debug" exited with code
-2147450730. Northwind.WebUI C:\Users\Adminuser\Documents\Visual Studio 2017\Projects\NorthwindTraders-master\Northwind.WebUI\Northwind.WebUI.csproj 60
Any Idea how to fix this issue?
Swagger doesn't like it when two or more endpoints in the same Controller share the same name. make use of routing attributes and make sure they are unique.
Try to install NSwagStudio then re open your visual studio.
That's should solve your problem.
If it's still not working
give a look about your output console when you try to compile your project, you should see something like this
1>Executing file 'nswag.json' with variables 'Configuration=Debug'...
1>Launcher directory:
C:\Users\Shadow.nuget\packages\nswag.msbuild\13.1.6\tools\NetCore30
You should have a file called dotnet-nswag.exe in your c:\user...\tools\netcore30 directory.
Put this exe in your environnement path.
Re open visual studio and your error should be gone.

MSBuild 15: The "Error" task could not be instantiated

I'm attempting to programmatically build a project which uses C#7, and therefore MSBuild 15, but this task is failing seemingly because of mismatched assembly references.
Here is my code:
string projectFilePath = Path.Combine(args.Any() ? args.First() :#"C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln");
ProjectCollection pc = new ProjectCollection();
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
globalProperty.Add("Configuration", "Debug");
globalProperty.Add("Platform", "x86");
BuildParameters bp = new BuildParameters(pc);
bp.Loggers = new ILogger[] { new Logger(), new ConsoleLogger(), };
BuildRequestData BuidlRequest = new BuildRequestData(projectFilePath, globalProperty, "4.0", new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(bp, BuidlRequest);
Here is the error message:
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4127: The "Error" task could not be instantiated from the assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.Error' to type 'Microsoft.Build.Framework.ITask'.
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4060: The "Error" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
Here is a link to a project you can use to recreate the issue:
https://drive.google.com/a/xibis.com/file/d/0B-mqMIMqm_XHcVRJQmtxQkd1b3c/view?usp=sharing
You will have to change the path in the code to a project on your own machine, but it doesn't seem to matter if this is a VS 2017 project or earlier.
One other thing that may or may not be relevant, I noticed that the Microsoft.WebApplication.Build.Tasks.Dll in this folder:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications
Still seems to be referencing Microsoft.Build.Framework.dll version 14, not 15 as I would have expected.
It turns out there are two issues in my test project. The first is due to the naming of the project.
However there is a second issue which is due to the references not being correct. To use MSBuild 15 programmtically you must install the following packages:
Install-Package Microsoft.Build -Version 15.1.1012
Install-Package Microsoft.Build.Framework -Version 15.1.1012
Install-Package Microsoft.Build.Tasks.Core -Version 15.1.1012
Install-Package Microsoft.Build.Utilities.Core -Version 15.1.1012
Install-Package Microsoft.Net.Compilers -Version 2.2.0
There is one more step which is nuts and completely undiscoverable. You must now add a reference to this DLL which should be relative to your solution folder:
packages\Microsoft.Net.Compilers.2.2.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll
I opened a support ticket with Microsoft and they have confirmed that this is a bug in Visual Studio 2017.
They are aiming to get a fix for this into update 3 for Visual Studio, but this may slip.
This issue tracks the bug:
https://github.com/Microsoft/msbuild/issues/2194
There is no workaround at present for this API, but you can invoke the MSBuild exe using Process as an alternative.
If you have MSBuild installed on your PC, either directly or through Visual Studio, the proper fix is to use the package Microsoft.Build.Locator which will find that installed version and execute the build using it.
Install these packages
Microsoft.Build
Microsoft.Build.Framework
Microsoft.Build.Locator
The first 2 are needed so that the code can compile but should be excluded from the project output.
In your application startup add the following line of code, this only has to run once.
Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();
Remove any additional binding redirects in your app.config that are specific to Microsoft.Build or other build libraries. The call to the Microsoft.Build.Locator assembly will ensure that these redirects take place automatically.
References
Update an existing application for MSBuild 15
Github MSBuildLocator.

Error installing Sql Server sink - Semantic logging

I'm trying to install Semantic logging Sql Server sink into my application but each attempt so far failed. The error I'm getting is (in CMD mode):
Attempting to resolve dependency 'EnterpriseLibrary.SemanticLogging (≥ 1.0)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 4.5)'.
Attempting to resolve dependency 'EnterpriseLibrary.TransientFaultHandling.Data (≥ 6.0)'.
Attempting to resolve dependency 'EnterpriseLibrary.TransientFaultHandling (≥ 6.0)'.
Installing 'EnterpriseLibrary.TransientFaultHandling 6.0.1304.0'.
You are downloading EnterpriseLibrary.TransientFaultHandling from Microsoft, the license agreement to which is available at http://www.opensource.org/licenses/ms-pl. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Install failed. Rolling back...
install-package : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
At line:1 char:1
+ install-package
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], PathTooLongException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Tried both UI and command prompt installations still no luck. Any help would be appreciated very much.
Had a similar problem. You might try to move just this single package to a shorter directory, e.g. C:\Packages. Otherwise move your whole project path (e.g. C:\users\yourname\documents...) to a short path like c:\MyProjects.

Visual Studio 2012 Hot towel template not working correctly

I am following this tutorial for getting started with Hot towel, I have installed the ASP.NET Web Tools 2012.2 update and have also downloaded and installed the VSIX for the Hot towel template, but when I try create a new project with this template it is not working correctly. If I open a new project in Visual Studio 2012 and select ASP.NET MVC 4 Web Application I see the HotTowel Single Page Application template listed there, but I select the project gets created with a lot of files missing.
What I would expect to see in my Scripts folder is the following:
But instead my project looks like this:
The project created also does not compile, it throws the following exception:
Error 1 The name 'BundleConfig' does not exist in the current context
This exception is being thrown here:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
Does anyone know why the Hot towel template is not working correctly in Visual Studio 2012 and what I could do to get it working?
UPDATE:
I tried installing Hot Towel with Nuget instead of the template, but that also did not work correctly. Install-Package got as far as installing Q and then gave an exception. Here is the Nuget output:
PM> Install-Package HotTowel
Attempting to resolve dependency 'Breeze.WebApi (≥ 1.4.1)'.
Attempting to resolve dependency 'Breeze.Client (≥ 1.4.2)'.
Attempting to resolve dependency 'Q'.
Install-Package : External packages cannot depend on packages that target projects.
At line:1 char:1
+ Install-Package HotTowel
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
I solved this problem by updating NuGet Package Manager. I updated it from here:
http://docs.nuget.org/docs/start-here/installing-nuget