How can I run dotnet tool install dotnet-ef -g in gulpfile - c#

I want to import my task in task.json into gulpfile, but I couldn't find an example.
The command I want to run in gulpfile: dotnet tool install dotnet-ef -g
Tasks.json :
"tasks": [
{
"label": "(EF) Install Entity Framework Cli",
"command": "dotnet",
"type": "process",
"args": [
"tool",
"install",
"dotnet-ef",
"-g"
]
}

Related

The program has exited with code -532462766 in Visual Studio Code + Asp.net core app

I can't figure out where to look for the reason of this:
I have asp.net core app (.net6)
When I try to launch app in Debug mode in Visual Studio 2022 - it's works well.
When I try to launch my app in debug mode in VS Code, I see follows:
Using launch settings from
'...\TelegramBot\Properties\launchSettings.json' [Profile
'TelegramBot']... Loaded 'C:\Program
Files\dotnet\shared\Microsoft.NETCore.App\6.0.8\System.Private.CoreLib.dll'.
Skipped loading symbols. Module is optimized and the debugger option
'Just My Code' is enabled. The program '[6592] TelegramBot.dll' has
exited with code -532462766 (0xe0434352).
my launch.json
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/TelegramBot.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
part of tasks.json
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TelegramBot.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
Many thanks to everyone who helps!
Changing property to x64 in .csprog file will resolve this problem. All because of I tried to launch x86 project over x64 sdk

Debugger wont launch .netcore application on Mac Only. (But works on Windows)

I am trying to run the .Net Core Launch(web) debugger. The debugger launches but the application never runs and thus the breakpoints never hits. Here are my launch.json settings. I have tried on a windows machine and it works perfectly fine but for some reason on the mac the debugger fails to launch and ends up not working. In the console, the debugger loads fine so I am not getting any errors.
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/abc/bin/Debug/netcoreapp3.1/abc.dll",
"args": [],
"cwd": "${workspaceFolder}/src/abc",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
},
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
Fixed:
Commenting out the TCP Output in my eventFlowConfig.json file fixed the issue.
The application uses websocket and seems like theres a bug in the mac client when trying to output it.
Specifically, under outputs of eventFlowConfig.json, I had to comment out the type:"socketOutput" section.

Asp.net Core 1.0 project.json prepublish scripts

Hey this is a part of my project.json file:
"scripts": {
"prepublish": [
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js",
"node node_modules/webpack/bin/webpack.js"
],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
I want to invoke prepublish scripts every time I publish the application even if it's a development environment and I am running it through visual studio or dotnet run. Prepublish doesn't seem to work in these cases
When you run through VS or using 'dotnet run', you only build and run the application from source, without publishing. Publishing scripts will be triggered, if you call dotnet publish.
The dotnet run command provides a convenient option to run your application from the source code with one command. It compiles source code, generates an output program and then runs that program.
Right now only the following types of script are supported:
precompile
postcompile
prepublish
postpublish
and what you want is more like "beforerun"/"postrun". As a workaround you may try to call your scripts directly from code in your application entry point.

Add DLL reference in dotnet cli

Is it possible to reference a c#/.net nuget package or dll using .net core cli tools?
https://github.com/dotnet/cli
None of the documentation seems to explain how to do it.
You add your references by simply editing the project.json file. Just add all of your references and nugets there. Then you can use the cli command to download them into your project by using the
dotnet restore
Here is an example project.json file. Under dependencies, you can see some nugets. Under framework assemblies, you can see a DLL reference, System.Data.
{
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"PimProject.Common": "1.0.0"
},
"frameworks": {
"dnx451": {
"dependencies": {
},
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
}
},
"dotnet": {
"dependencies": {
"System.Data.SqlClient": "4.0.0-rc2-23530",
"System.Data": "4.0.0"
}
},
"version": "1.0.0-*",
"description": "Class Library",
"authors": [ "sadams" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": ""
}
Starting on version 1.0.1, dotnet cli allows to add references to packages and projects using add command:
dotnet add package EntityFramework
To add a reference to project Proj2 in Proj, move to Proj folder and use
dotnet add reference "..\Proj2\Proj2.csproj"

Restore package failed for `Microsoft.Dnx.Compilation` in asp.net 5 rc1-final

I am using Dnx compilation engine to compile a c# package class library.but when i add a reference to preceding package in project.jsonfile i end up with following message :
The dependency Microsoft.Dnx.Compilation 1.0.0-rc1-final in project
[x] doest not support framework .Net Framework Version v4.5.1
But i toke a look at DNX source code and saw a reference for framework v4.5.1 there.following picture is an evidence for what i've mentioned.
Any idea why this happens?
{
"version": "1.0.0-*",
"description": "Tourism.Framework Class Library",
"authors": [ "Behnam" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Data": "4.0.0.0"
}
}
},
"dependencies": {
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final",
"Autofac": "4.0.0-rc1-177",
"Microsoft.AspNet.Mvc.Razor": "6.0.0-rc1-final",
"AutoMapper": "4.1.1",
"log4net": "2.0.4",
"Microsoft.Dnx.Compilation" : "1.0.0-rc1-final"
}
}
The Microsoft.Dnx.Compilation package targets DNX 4.5.1 (dnx451) and DNX Core 5.0 (dnxcore50) as it requires DNX. It does not target the standard, full .NET framework v4.5.1 (net451).
If you want to use it, you should target dnx451 in your project.json. This is the preffered target framework: Apps should target dnx451 and class libraries should target net451 (see this issue).

Categories