1
votes

I am developing a Web Application with ASPNET Core 2.0 on Visual Studio Code on Linux. But the host I'm trying to deploy the application is a Windows Server and the only target available option is .Net Framework 4.6.

So, when I try to run dotnet publish -o /folder -f net461 it shows me this error.

Is it possible to develop an aspnet core application on linux and deploy it on windows using .Net Framework?

The following is the text of the error:

/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/maransatto/Projects/FATEC/EraDoConhecimento/web/BDAg.csproj]

1

1 Answers

1
votes

There are 2 scenarios: ASP.Net Core with .Net framework and ASP.Net Core with .Net Core. You can't develop asp.net core with .net framework on linux, so probably your application's target is "netcoreapp2.0" (suposed you downloaded the latest version). It's ok you deploy your app on windows server just using .net core runtime 2.0.

your command should be

dotnet publish -c Release -f netcoreapp2.0

You can deploy Framework-dependent or self-contained version. See (https://docs.microsoft.com/en-us/dotnet/core/deploying/index).

You also need Asp.Net Core Module on windows with IIS Integration. https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x

When publishing self-contained you don't need .net core to be installed on the server.