NEO Contract Development - Common Pitfalls using Windows 7

in #neo7 years ago (edited)

Screen Shot 2017-10-10 at 2.30.07 PM.png

If you're thinking about developing a contract for NEO, you might find that setting up the development environment is a bit "raw" at the moment. If you're not a regular Windows user, you may catch yourself stuck early on in the build process.

This article is meant to supplement the C# guide for Windows on the Neo.org website, specifically for issues I ran into on Windows 7.

If you plan to develop NEO Smart Contracts using Linux or Mac OS X, you'll need to use the Python tools at the moment. (Thanks to @qed for pointing this out.) While Visual Studio is available for Mac and Linux, the NEO plugin only supports Windows right now.

You can use a VM for Windows, but if you have an old Windows desktop or laptop lying around, you can use Windows 7. The process to get NEO Contracts running on Windows 7 is a bit trickier than the guide lets on, but I hope my trial and error can clear the way for you. I've ordered the following points to follow the order that the issues came up while compiling Neon and the example project.

Errors with NuGet

Problem: When you try to publish the neon package, you might come across an error which tells you to run the NuGet Restore option. However, even if you try to restore using the Visual Studio UI, the same error comes up again, trapping you from resolving the issue.

Solution: You'll want to download the official NuGet executable from their website. Once you have that, copy the .exe into the root directory of the neo-compiler project. Then, open up the command prompt, change your directory to the same root neo-compiler directory, and then run nuget restore.

Errors with neon.dll

Problem: Following the above issue, you might still not be able to publish your project. In this case, an error comes up that "neon.dll" does not exist within obj/Release/netcoreapp1.0/win10-x64/.

Solution: If you take a look at the parent directory, obj/Release/netcoreapp1.0/, you should find the neon.dll library. Go ahead and copy the .dll into the child directory, and then try again to publish the project.

Download the api-ms-win-core-console-l2-1-0.dll DLL

Problem: After you add the neon directory to your Path environment variable, you may come across an error trying to run the neon program in the command prompt, which tells you that api-ms-win-core-console-l2-1-0.dll is missing.

Solution: The NEO C# manual addresses this, but for good measure, you'll need to download the api-ms-win-core-console-l2-1-0.dll library and place it into the C:\Windows\System32 directory. However, I found that I needed to use the 64-bit DLL in order to get the neon program to run successfully.

Also, downloading DLLs is very sketchy. I personally pulled mine from dll-files.com. If anyone runs into any problems with this, please share in the comments. It's generally a major security hazard to download and use DLLs.

Building NeoContract - Neo namespace not found

Problem: When trying to build NeoContract1 (your first Neo Contract to check that everything is plugged in correctly), you may run into a namespace issue where Neo is not found.

Solution: Just like the solution for NuGet before, we need to copy nuget.exe into the root directory of our project. Copy nuget.exe into the same folder as the NeoContract1 solution. Then, open the command prompt, change your working directory to the location of the NeoContract1 solution, and run nuget restore.

Building NeoContract - Build stops after "Start NeoContract converter" step

Problem: When you're trying to build the NeoContract1, you might find that the build fails despite no clear error. It prints the first two lines just like the example image in the C# guide, but then it stops and fails.

Solution: If you haven't restarted Visual Studio or Windows since you started the C# setup process (and, I suspect, since you added neon to your Path), you might need to either restart Visual Studio or Windows. For good measure, coming from a Mac and Linux background, I restarted Windows, which fixed the problem.

That's It!

I hope this helps to guide you through any common pitfalls. If you have other pitfalls to share, comment them below. If you have better suggestions for solutions, let me know, and I'll update the above list.

Good luck, and happy coding!

Sort:  

Interesting Good Luck

Thanks for the summary of potential problems together with their solutions.
I'm looking forward to read more.

Thanks! I tried to set up the development environment month ago but I couldn't do that by myself. With this guide I succeeded, I got most of theses pitfalls.

Your post now gets a mention in the corresponding video tutorial :)

Congratulations @cybourgeoisie! You have received a personal award!

1 Year on Steemit
Click on the badge to view your own Board of Honor on SteemitBoard.

Upvote this notificationto to help all Steemit users. Learn why here!

Congratulations @cybourgeoisie! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Are you a DrugWars early adopter? Benvenuto in famiglia!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!