简体   繁体   English

如何在远程服务器上构建 .net 应用程序?

[英]How do I build a .net application on a remote server?

This question is probably more about me not knowing terminology than anything.这个问题可能更多是关于我不知道术语而不是任何东西。 For reference, I come from a background of "build a website in PHP/wordpress then drag and drop files into FTP - boom website works"作为参考,我来自“在PHP/wordpress中建立网站然后将文件拖放到FTP - 繁荣网站工作”的背景

I've built an .NET application that runs locally in Visual Studio.我已经构建了一个在 Visual Studio 中本地运行的 .NET 应用程序。 All is good there.那里一切都很好。 It's built using the Sitefinity nuget package if that's important.如果这很重要,它是使用 Sitefinity nuget 包构建的。

I fired up a remote windows server and configured IIS via IIS Manager and a tutorial I found.我启动了一个远程 Windows 服务器并通过 IIS 管理器和我找到的教程配置了 IIS。 I moved my application files (via Git) to this server and pointed the thing at my files.我将我的应用程序文件(通过 Git)移到了这个服务器上,并将这个东西指向了我的文件。 I can now go to localhost/SitefinityTest and see the site.我现在可以转到localhost/SitefinityTest并查看该站点。

Except instead of the page, I get errors.除了页面之外,我收到错误。 I don't think these are errors with the application (again, works fantastic locally in VS) but something wrong with how I deployed this.我不认为这些是应用程序的错误(同样,在 VS 中本地工作得很好)但是我部署它的方式有问题。

Could not load file or assembly 'Telerik.Sitefinity' or one of its dependencies. The system cannot find the file specified.

My first thought is that something is missing.我的第一个想法是缺少某些东西。 At first glance, the packages directory is simply not there, so I copy-paste this from my local into my server.乍一看,packages 目录根本不存在,所以我将它从本地复制粘贴到我的服务器中。 No change.没变。

- C:\SitefinityTest
  - SitefinityTest (this is where my server is pointing)
    - ... all my files
  - packages (this is the missing directory I manually copied over)
  .gitattributes
  .gitignore
  SitefinityTest.sln

I'm also thinking there's some "build" step, similar to hitting "run" in VS that needs to happen before the application will work on this server?我还认为有一些“构建”步骤,类似于在应用程序在此服务器上运行之前需要在 VS 中点击“运行”?

Again, this is not my forte.再说一遍,这不是我的强项。 I'm primarily a front-end developer and I understand MVC and code and can actually build out an application, but I don't have any fundamental understanding of how things happen behind the scenes.我主要是一名前端开发人员,我了解 MVC 和代码,并且实际上可以构建一个应用程序,但我对幕后发生的事情没有任何基本的了解。 If there's some glaring incorrect assumption I've made please let me know.如果我做出了一些明显不正确的假设,请告诉我。

I think you may want to try using the “publish” function built into Visual Studio. 我想你可能想尝试使用Visual Studio内置的“发布”功能。 You should be able to point it at your server. 您应该能够将它指向您的服务器。 I don't remember what all is involved in the process, but it's worked for me in the past. 我不记得这个过程中涉及的是什么,但它在过去对我有用。

This article may help. 这篇文章可能有帮助。

https://docs.microsoft.com/en-us/dotnet/core/tutorials/publishing-with-visual-studio https://docs.microsoft.com/en-us/dotnet/core/tutorials/publishing-with-visual-studio

Normally DLL files are not committed to Git - only the source code is committed. 通常DLL文件不会提交给Git - 只提交源代码。

That's why, on your server most probably the Bin folder is empty, hence the missing dll error. 这就是为什么在你的服务器上很可能Bin文件夹是空的,因此缺少dll错误。

You are right - you are missing the "build" step here. 你是对的 - 你错过了这里的“构建”步骤。

If you have a visual studio on the server - you can build the application with it - that will generate the dlls in the bin folder from the source code. 如果您在服务器上有可视工作室 - 您可以使用它构建应用程序 - 这将从源代码生成bin文件夹中的dll。

If not, you can manually copy the entire bin folder from your localhost to the server. 如果没有,您可以手动将整个bin文件夹从localhost复制到服务器。

On a side note, we don't use VMs anymore - we use Azure App Service. 另外,我们不再使用VM了 - 我们使用Azure App Service。 We bind it to a github repo and when we push a change to the repo - Azure pulls latest from github, builds the solution and deploys the site. 我们将它绑定到github仓库,当我们将更改推送到repo时 - Azure从github获取最新信息,构建解决方案并部署该站点。

I like this automatic build option a lot. 我非常喜欢这种自动构建选项。

In your case, you will have to manually do that step - either build on the server or simply copy the dll files yourself. 在您的情况下,您将不得不手动执行该步骤 - 在服务器上构建或只是自己复制DLL文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM