简体   繁体   English

Nuget:部署到IIS或共享代码

[英]Nuget: Deploy to IIS or Share Code

This is the first time I have used NuGet and I think my question may be so basic that I can't find the answer. 这是我第一次使用NuGet,我认为我的问题可能太基本了,无法找到答案。

Question 1) 问题1)

I downloaded NuGet packages on VS2012 我在VS2012上下载了NuGet软件包

-Install-Package EntityFramework -Version 6.1.0 -Install-Package Microsoft.AspNet.Web.Optimization

When I create a copy of my application code, a VS2012 C# asp.net website directory and try to run it without a solution I get an error that looks like the website is not finding the Nuget packages. 当我创建应用程序代码的副本,VS2012 C#asp.net网站目录并尝试在没有解决方案的情况下运行它时,出现一个错误,好像该网站未找到Nuget软件包。

If I need to share a code directory with a colleague so they can help work on it what is the process to do that? 如果我需要与同事共享代码目录,以便他们可以帮助您进行处理,那么该流程是什么?

When it comes time to deploy the code directory to IIS in production what is the process to do that? 到了在生产环境中将代码目录部署到IIS的时候了,这样做的过程是什么? Can I simply copy the code over to the webserver as previous? 我可以像以前一样简单地将代码复制到Web服务器上吗? Are there steps to take to ensure the Nuget packages are referenced? 是否要采取步骤确保引用了Nuget软件包?

Further details below: 以下是更多详细信息:

Using VS 2012 I added the following NuGet packages to the solution: 使用VS 2012,我向解决方案中添加了以下NuGet软件包:

Install-Package EntityFramework -Version 6.1.0 Install-Package Microsoft.AspNet.Web.Optimization

My target version is .NET framework 4.0 to match production. 我的目标版本是.NET Framework 4.0以匹配生产版本。

When I move the code to another location on my computer or share it with a colleague it generates the error below. 当我将代码移到计算机上的其他位置或与同事共享时,将在下面生成错误。

Server Error in '/Portalv4' Application.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?)

`Source Error: Line 64: public DateTime FailedPasswordAnswerAttemptWindowStart { get; `源错误:第64行:公共DateTime FailedPasswordAnswerAttemptWindowStart {get; set; 组; } Line 65: Line 66: [Column(TypeName = "ntext")] Line 67: public string Comment { get; }第65行:第66行:[Column(TypeName =“ ntext”)]第67行:公共字符串Comment {get; set; 组; } Line 68: }第68行:

` `

OK here is a weird thing- if I switch VS2012 to run the project under IIS Express the it will compile and run just fine. 好的,这很奇怪-如果我将VS2012切换为在IIS Express下运行项目,它将可以编译并正常运行。 Any ideas as to why it does not work under Visual Studio Development server once it is separated from the solution file? 将其与解决方案文件分离后,为何在Visual Studio Development Server下不起作用的任何想法? There are many dll warnings about not being able to refresh under both VS Dev Server and IIS express. 关于在VS Dev Server和IIS express下都无法刷新的许多dll警告。

Your application's ability to compile does not depend on your NuGet packages directly. 您的应用程序的编译能力并不直接取决于您的NuGet软件包。 The packages.config file simply remembers what was installed with NuGet so that it can manage updating and uninstalling of packages. packages.config文件只记得NuGet随什么安装的文件,因此它可以管理软件包的更新和卸载。

However, when you install a NuGet package, it will add files throughout your project. 但是,当您安装NuGet软件包时,它将在整个项目中添加文件。 Once you install or remove a package, be sure to save your Project so that references to the package are saved. 安装或删除软件包后,请确保保存您的Project,以便保存对该软件包的引用。 If you copy your project before saving, the package files will be in the project directory but you won't see them in the VS Solution Explorer. 如果在保存之前复制项目,则软件包文件将位于项目目录中,但在VS Solution Explorer中将看不到它们。

Regardless of whether this is the cause of your error. 不管这是否是导致您出错的原因。 You can track down the error by going to your original project, determine what assembly defines 'Column' (as described in the error) and make sure that the assembly is in the References folder of the copies project. 您可以通过转到原始项目来查找错误,确定哪个程序集定义了“列”(如错误中所述),并确保该程序集位于副本项目的“引用”文件夹中。

Good luck. 祝好运。

If I need to share a code directory with a colleague so they can help work on it what is the process to do that? 如果我需要与同事共享代码目录,以便他们可以帮助您进行处理,那么该流程是什么?

Start using source/version control technology, for example Git or Team Foundation Server (TFS) . 开始使用源/版本控制技术,例如GitTeam Foundation Server(TFS) Both integrate nicely in Visual Studio. 两者都很好地集成在Visual Studio中。 TFS is available for free for up to five users. TFS可供多达五个用户免费使用。

Once you're using source control, make sure to choose 'Enable Nuget Package restore' in your solution (right-click the solution in Solution Explorer). 使用源代码管理后,请确保在解决方案中选择“启用Nuget软件包还原”(在解决方案资源管理器中右键单击解决方案)。 Without this option enabled, all Nuget packages will be added to your source control and you don't want that. 如果不启用此选项,则所有Nuget软件包都将添加到源代码管理中,而您不希望这样做。

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

相关问题 如何将IHttpHandler代码部署到IIS - How to deploy IHttpHandler code to IIS 如何打包和部署带有符号和源代码的 NuGet 包,以便调试器可以使用该源代码? - How to package and deploy a NuGet package with symbols and source code so that debugger can use THAT source code? 如何通过 NuGet 包共享源代码以用于 .NET Core 项目 - How to share source code via NuGet packages for use in .NET Core projects 将Web服务部署到Nuget包 - Deploy Web Service to Nuget Package 将WebAPI(aspnetcore 2)部署到IIS - Deploy WebAPI (aspnetcore 2) to IIS 将WPF应用程序部署到IIS - Deploy WPF Application to IIS 在IIS中部署网站 - Deploy Website in IIS 在 IIS 中部署 Silverlight 应用程序发生错误错误代码 2105 无法加载 Silverlight 先决条件 - Deploy Silverlight application in IIS error occured ERROR Code 2105 Failed to load Silverlight Prerequisites 在Windows 10的IIS 8.5中部署的WCF服务应用程序可永久加载而不会出现错误代码 - WCF Service Application deploy in IIS 8.5 on Windows 10 keep loading forever without error code .NET 核心 3 API,在 Mac 上使用 Visual Studio Code 开发:如何在 IIS 上部署和配置? - .NET core 3 API, develop on Mac with Visual Studio Code: how deploy and configure on IIS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM