How do I run an ASP.Net Core executable file? - asp.net

I am new to ASP.Net Core. I have been following a tutuorial. I got to the point at which Javascript code was added to my project. I ran my program, and nothing in the script worked. After adding a few alert() calls, it was apparent that my program was not finding my script. People here and at Reddit suggested I look at the network tab of DevTools. I saw that my program was not able to find any js or css files.
Being an old-school C++/C# developer, I was running the program from a command window by going to the folder containing the executable file and typing the name of the file.
I went back to the beginning. The tutorial directs me to use the dotnet command, which is brand new to me. The first time it tells me to run my program, it tells me to go to the project directory and enter "dotnet run". It just hit me like a ton of bricks that that was what I should have done the first time. I went back to that project, used "dotnet run", and it worked.
So, my question is this: is it possible to run MyProject.exe by itself? If so, how? Copy it into my project folder? Or is the "dotnet run" command the standard way of executing an ASP.Net Core application?

I think it won't work if you directly run it (not sure if we can run MVC project using dotnet-cli (dotnet run will try to load only MSIL to CLR)).
DotNet core console application is different from .net core MVC projects
you can run your project by following ways.
1. Run using visual studio
when you create an MVC application, in the visual studio there will be multiple options to run it, you can choose IISexpress one, it will open in the default browser.
for step by step guide -> https://learn.microsoft.com/en-us/visualstudio/ide/quickstart-aspnet-core?view=vs-2019
2. publish it in IIS
For this you need to ensure few things, like hosting bundle is installed or not, IIS is correctly configured for core application or not.
for step by step guide -> https://stackify.com/how-to-deploy-asp-net-core-to-iis/
3. Use VSCode
for step by step guide -> https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-webapp-using-vscode?view=aspnetcore-3.1

Related

Possibility of using dotnet to run / watch a LibraryType project that is linked to another application

I am exploring the possibilities of utilising the dotnet SDK to run and watch a LibraryType project, where the compiled dll will be linked and used by a 3rd party application.
I have tried setting up a launchSettings, which works when I am running the project via Visual Studio. However, I am wondering if it is possible to set up the settings to run this entirely in CLI through dotnet SDK.
I have tried searching for references on this, but the result points towards creating another executable project which I am not entirely sure how it would work if I have to link the dll to a 3rd party application.
The current workflow consist of the following commands:
dotnet build
[path-to-app] [path-to-build-dll]

.NET Core 31 - Single EXE - The application to execute does not exist

Converted an old .NET Framework project to .NET Core 3.1 yesterday. The application runs fine on my own machine and debugs correctly.
I have put both the following into my .vbproj/.csproj
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win81-x64</RuntimeIdentifier>
However when I move the .EXE to a remote machine and attempt to run said EXE on that remote machine I get told that the DLL (for the project in question) does not exists.
I moved the .dll to the same directory that the exe is in (not ideal) and get the following error instead
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
I used to use Costura.Fody to create a single file exe without any issues in .NET Framework, I was under the impression the above would do the same for the .NET Core packages.
Can someone point me in the right direction please.
For anyone else that may find this question and find it useless.
I was 'Building' the project instead of 'Publishing' the project, this in-turn wasn't creating the self-contained exe properly.
Don't be a donut like me.
In Visual Studio 2019, go to Build > Publish MyApp. This will open a tab in the editor area. Click on Show all settings to open the Profile settings dialog. Then click on File publish options and check Produce single file.

How to build .NET CORE project in VSCode or command line?

I tried to switch from Visual Studio to Visual Studio Code with my CORE project. I can build the C# project in Visual Studio without any problems. When I tried VSCode, I see that I need to define tasks. Fortunately, VSCode offers default tasks definition (it generates tasks.json) for me, so I tried them (there are variants for CORE and .NET, as I understand). But both don't work. I tried to make build from command line, but get error (I translate the error to English, it's not original text):
C:\Program Files\dotnet\sdk\2.1.700\Microsoft.Common.CurrentVersion.targets(3046,5): error MSB4216: can not execute task "GenerateResource", because MSBuild cannot create tasks server with execution environment "CLR4" and architecture "x86" or to connect to it. Verify that, (1) required execution environment and architecture do exist and (2) required executable file "C:\Program Files\dotnet\sdk\2.1.700\MSBuild.exe" exists and can be ran. [D:\prj\...\Test.csproj]
and when I tried to find MSBuild.exe in this folder, I found MSBuild.dll only, no any MSBuild.exe. So, I tried to run it with dotnet after entering this folder - it works. But if I try to call dotnet build or to run it with full path to MSBuild.dll from my project folder, I always get this error. Seems, that dotnet command calls MSBuild.dll multiple times and always hit this problem. May be I should setup some paths or similar. But where to do it (without to break ability to build the project in Visual Studio)? What is the convenient way to build CORE projects in Visual Studio Code? How to build them in command line?
PS. May be all documentation which I found was outdated...

How to create a BizTalk Application btaproj

I am using BizTalk 2016 and I want to enable build from VSTS.
Build fails because it asks for some *.json files.
After some investigation I reached the conclusion that I have to create
a btaproj file. Add a BizTalk Server application to Visual Studio Team Services
I installed Feature Pack 1 but there is no option for BizTalk Application project.
How can I create a btaproj file?
Did you select .NET Framework 4.6.1 in create new project dialog?
fr step by step instructions, please follow https://www.codit.eu/blog/2017/05/02/bts-2016-feature-pack-i-continuous-deployment-walkthrough/
I used the steps described in usman-shaheen post
Then I had an error during building. In project's properties, under Build Events -> Post-build events there were some commands, probable written by VS. These commands were causing an error during building. If I was starting VS as admin, they were not causing any error and building was finished correctly. By removing these commands, agent could run and build my app.

Add .Net Framework 2.0 in VS Setup Project

I have setup project that requires .Net Framework 2.0 before installation. So, I want to make my project to install .Net first and then my project.
How can I add .Net installation file inside my Setup Project and force it to install first during the installation process?
here
here
You can also download the setup file of the .net framework and use setup maker applications to instruct the user to install it first. Please do a little web search for similar questions before asking here. :-)
EDIT:
First create a setup file for your visual studio project without the .net framework setup file. Then use Inno Setup to make another setup file and in here use the option Inno setup provides to make the user to run the .net framework setup file first. This will make a single .exe file named setup.exe in you documents folder. See if this works for you.
Since .net framework and your program use the same install shield for installing, you can't use both of them at the same time when the other one is still running, that's why you need a different setup wizard than install shield.
EDIT(Inno Setup):
You can search Run in the index section of the help window for farther information. The programs are executed in the order appearance in your code in Inno Setup. So your Inno Setup Run section code should be something like this:
Filename: "{app}\.netFrameWorkSetup.exe"; Flags: nowait postinstall skipifsilent
Filename: "{app}\yourAppSetup.exe";
Actually it didn't get as much explaining as I expected!

Resources