I am trying to publish a new .net API to IIS. because this needs to be done to a production server I am trying this with a sample API project and a test server to figure out how to go about this first.
I used this as a reference.
The project uses .net 5.0 I installed the windows .net core hosting bundle v5.0.6 I installed the windows .net core runtime v5.0.6
I created an application pool and website in IIS following all the necessary steps.
The sample project is just the most basic .net core web API project you can get, just clicked web API and changed nothing, this has only 1 endpoint and a swagger page.
When I publish it to the test server and try to view the swagger page in the browser I get a 404.
If I run the project exe with dotnet "Projectname".exe I get the following error message:
D:\ThirdPartyAPI>dotnet Test.exe
Error:
An assembly specified in the application dependencies manifest (Test.deps.json) has already been found but with a different file extension:
package: 'Test', version: '1.0.0'
path: 'Test.dll'
previously found assembly: 'D:\ThirdPartyAPI\Test.exe'
I tried editing Test.deps.json
, but I am not sure what to delete, and every time I edit it The assembly becomes invalid.
I tried switching the project/runtime and appplication pool to 32 bits, bubt the same thing happened.
The same thing happens if I type dotnet publish
in the package manager console and then run the api locally by going to the published folder and using the command dotnet run Test.exe
I tried every possible solution I could find on other SO posts, but nothing changed anything.
I added <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
to my csproj, but again nothing happened.
I tried removing a duplicate in my Test.deps.json from the libraries key, some other SO post recommended this, but this made the assembly invalid.
I am all out of ideas right now and would like to finish this so I can move on.
I will provide any additional information if needed, Thank you in advance!
I tried the same process with a sample API in .net core 3.1, this worked on the first try. It is maybe possible to port the real API back to 3.1, but this is definitely not preferred.