I have faced with a problem in my dotnet api project .
I have project.csproj file but still this error while dotnet run command.
Couldn't find a project to run. Ensure the project exists in path.
I build the project via (dotne new project -o Myproject -n Myproject )
Command I don't know what is wrong please help me out of the problem.
you need to add Template and lang
(Template options)
check this here!
Related
I want know what is the command line for making a directory a startup project.
I have 2 directories inside EmployeeManagement and on sln file:
Models
Web
Employeemanagement.sln
Now instead of Right clicking and making Web the startup project, is there a way of doing it using command line interface.
Thanks for your help.
In the .Net 5.0, you can do: dotnet run --project , everytime you need to run the project.
CLI Example:
dotnet run --project Web/Web.csproj
I have been trying to build the following project structure with dotnet cli on netcoreapp3.1:
project_root:
project.sln
projecct1
--------project1.csproj
project2
--------project2.csproj
third_party
--------third_party1
------------third_party1.csproj
The third party project is referenced in one of the projects and it is in its self a netsandard2.0 assembly
running dotnet build produces the following error:
error NETSDK1005: Assets file '...\third-party\third_party1\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.1'. Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project.
Building the third party on its own works fine.
I realize that the error stems from the structure of the project. Any ideas how I can build the project with getting this error?
Ok so answering my own question. The problem was not the structure. When I built the project in command line I use dotnet build -c Release -f netcoreapp3.1
Since the project is a mix of netcoreapp3.1 and standard2.0 assemblies the standard2.0 assemblies failed to compile. If your framework is set in the csproj file not need for -f apparently.
If I create a net core 2 console app and get it to reference another project e.g. MyLibrary.csproj
This (MyLibrary.csproj) is a net core class library
If I run dotnet publish -c release --output test1
then in the output folder their is a runtime folder present
I have not found anywhere that describes this folders purpose.
Any one have a link?
Also do I need to copy this as part of my deployment?
The example I have has a reference to System.Data.SqlClient.dll which is present in the root publish folder(test1) so why does it need to get it from the runtime folder when I try to run via dotnet my.dll?
From the docs (https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore2x)
dotnet publish - Packs the application and its dependencies into a folder for deployment to a hosting system.
It might be a silly question, Let's say I don't have a Windows OS, have a Linux. I have created a .Net core console app, also want to create a class library and reference it in console app. I can't find if i am able to do it also couldn't find a sample on Microsoft .Net core page.
Is there an extension in vs code? Or isn't it possible with it?
If i am mistaken could you please guide me?
The best way to do it is from the console, since you are using the latest supported templates this way. VSCode also has an integrated terminal you can use for this.
$ dotnet new lib -o MyLib
$ dotnet new sln #assuming there is no .sln file yet. if there is, skip this
$ dotnet sln add MyLib/MyLib.csproj
$ cd MyConsoleApp
$ dotnet add reference ../MyLib/MyLib.csproj
If you need different frameworks, you can use the -f argument:
$ dotnet new lib -o MyLib -f netcoreapp2.0
or manually change the <TargetFramework> element inside the generated .csproj file.
I have an ASP.NET core application that I've been auto-deploying to an azure app service on commit to a git repo. It worked fine as a project.json type project.
I've converted my project.json to myproject.fsproj and it builds and runs locally. On comitting the .fsproj to git, the deployment was triggered, but it failed with the activity log containing one line: 'D:\home\site\repository\myproject.fsproj' is not a deployable project.
I guess it's an issue with the default kudu deployment script? Does anyone know how to sort this out, or do I need to submit an issue/RFC to the kudu guys?
UPDATE
I generated the original .fsproj using:
dotnet new mvc --language f# --framework netcoreapp1.0
I've since made changes to it, so I will try to do a minimal case later tonight.
Turns out that the default deployment in azure wouldn't deal with this.
Following the answer on Kudu Deployment Script for ASP.NET Core 1.0, I generated a custom deployment script using:
npm install -g kuduscript
kuduscript -y --aspNetCore myproject.fsproj
Added the resulting deploy.cmd along with a .deployment:
[config]
command = deploy.cmd
A deployment triggered by a push to git works as expected now.