简体   繁体   中英

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.

Question 1)

I downloaded NuGet packages on VS2012

-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.

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? Can I simply copy the code over to the webserver as previous? Are there steps to take to ensure the Nuget packages are referenced?

Further details below:

Using VS 2012 I added the following NuGet packages to the solution:

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

My target version is .NET framework 4.0 to match production.

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; set; } Line 65: Line 66: [Column(TypeName = "ntext")] Line 67: public string Comment { get; set; } Line 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. Any ideas as to why it does not work under Visual Studio Development server once it is separated from the solution file? There are many dll warnings about not being able to refresh under both VS Dev Server and IIS express.

Your application's ability to compile does not depend on your NuGet packages directly. The packages.config file simply remembers what was installed with NuGet so that it can manage updating and uninstalling of packages.

However, when you install a NuGet package, it will add files throughout your project. Once you install or remove a package, be sure to save your Project so that references to the package are saved. 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.

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) . Both integrate nicely in Visual Studio. TFS is available for free for up to five users.

Once you're using source control, make sure to choose 'Enable Nuget Package restore' in your solution (right-click the solution in Solution Explorer). Without this option enabled, all Nuget packages will be added to your source control and you don't want that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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