The new csproj is lightweight, you don’t have to unload the project to edit the csproj file and you can add package references directly to the csproj file, save it and they will be restored in your assembly automatically. Also, alleviates a lot of pain that’s inherent with Nuget package hell in the old csproj and packages.config style of doing things.

Overall, no reason not to migrate. The way to do it is as follows (for WebJobs and class library type projects):

  • Right click the packages.config and click the option to migrate to the new PackageReferences style. This will move all the package references in your csproj file and get rid of the packages.config file.

migrate to new pr

  • Right click on the project -> Unload Project -> Edit {project-name}.csproj. Make      sure the structure looks like this (this template so far has worked for me) and do whatever is necessary to make it so i.e. delete XML nodes and sections, rename nodes etc but make sure you keep all your package references:

         

  • Save, reload and build the project. You will get a few build errors to do with AssemblyInfo.cs file just open that file and remove these lines:

         

Rebuild! You’ve successfully upgraded the old csproj to the new csproj format with PackageReferences!

Just to confirm, right click the project and you should see “Edit {projectname}.csproj” in the menu which you couldn’t with the old format unless you unloaded the project first.

edit proj

NB: I would recommend doing this in a source controlled environment so that you can revert changes if something does go wrong with this migration. I haven’t tried this migration with all the project types so you might need to do additional research for your needs and then please do let me know.

Join the conversation! 1 Comment

  1. […] I need to first convert my .NET web job project to use the new csproj format. You can check out my article on how to do this and then come back […]

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Category

best practices, Uncategorized

Tags

, , , , ,