NEO Blockchain C# Developers Center of Excellence
The neo-csharpcoe
project is an "umbrella" project for several initiatives related to providing tools and libraries (code), frameworks, how-to documentation, and best practices for enterprise application development using .NET/C#, C#.NEO and the NEO Blockchain software platform.
The neo-csharpcoe
is an independent, free, open source project that is 100% community-supported by people like yourself through your contributions of time, energy, passion, promotion, and donations.
To learn more about contributing to the neo-csharpcoe
, click here.
The purpose of this activity is to build the NEO developer tools from the sources downloaded and unpacked in the previous activity.
- Ensure you have a working and properly configured set of NEO developer tools for creating and building smart contracts in Visual Studio with the C# programming language
- Provide reliable documentation: timely, accurate, visual, and complete
- Save as much of a person's time as possible
- Use open source software whenever possible
- Need in the NEO .NET developer community to have concise and easy-to-follow documentation to enable people to get up to speed developing NEO smart contracts in as short a time as possible
-
Open the neo-compiler project in Visual Studio by double-clicking
neo-compiler.sln
in theC:\NEO\neo-compiler-master\neo-compiler-master
folder created in Activity 2 - Download and unpack NEO developer tool projects (source).Figure 5.1. Open
neo-compiler.sln
in Visual Studio 2017 -
Uncheck the message
Ask me for every project in this solution
and clickOK
.Figure 5.2. Visual Studio: Uncheck the message
Ask me for every project in this solution
and clickOK
-
Visual Studio will open with the project displayed in the Solution Explorer to the right.
Figure 5.3. Visual Studio: Solution Explorer
-
Right-click the solution name
neo-compiler
near the top of the Solution Explorer and select Rebuild Solution. Several things will happen the first time you do this; for example, the referenced Nuget packages will be downloaded and refreshed in addition to the sources being compiled to create the NEO compiler set.Figure 5.4. Visual Studio: Rebuild Solution
-
Rebuild Solution completes.
Figure 5.5. Rebuild Solution completes
-
Right-click the project name
neon
in the Solution Explorer and select Publish.NOTE: This is the single most troublesome set of tasks in the entire Quick Start process. Follow these manual workarounds carefully.
Figure 5.6.
neon
Project: Publish... -
The following Publish page will appear in Visual Studio. Select
Publish
on the left side (and not Connection Services). Click thePublish
button to continue (using the default settings).Figure 5.7.
neon
Project: Publish to Folder -
When you see "Publish failed", this is the problem area. Click
OK
to close this dialog box.Figure 5.8.
neon
Project: Published failed -
In the Output pane at the bottom of the screen, change the drop down "Show output from:" from Build to
Build Order
. Note the highlighted error message about the missing neon.dll. It's not missing - it is in a different directory and needs to be manually copied to where Visual Studio expects to find this DLL.Figure 5.9.
neon
Project: neon.dll is missing (but not really) -
Open Windows Explorer and navigate to the folder
C:\NEO\neo-compiler-master\neo-compiler-master\neon\bin\Release\netcoreapp1.0
. We need to copyneon.dll
from this folder to the folder where Visual Studio expects to find it.Figure 5.10.
neon
Project folder:C:\NEO\neo-compiler-master\neo-compiler-master\neon\bin\Release\netcoreapp1.0
-
Right-click on
neon.dll
and selectCopy
.Figure 5.11.
neon
Project folder: Copyneon.dll
to the clipboard -
In Windows Explorer, navigate to
C:\NEO\neo-compiler-master\neo-compiler-master\neon\obj\Release\netcoreapp1.0
. Right-click in the file list and selectPaste
to paste a copy ofneon.dll
into this folder.NOTE: This is the obj/Release/netcoreapp1.0 folder path.
Figure 5.12.
neon
Project folder:C:\NEO\neo-compiler-master\neo-compiler-master\neon\obj\Release\netcoreapp1.0
-
Back in Visual Studio, click the
Publish
button to publish theneon
project files a second time (using the default settings).Figure 5.13.
neon
Project: Republish the Project -
This time, Publish completes successfully.
Figure 5.14.
neon
Project: Publish Succeeded -
The
neon
project files have been published toC:\NEO\neo-compiler-master\neo-compiler-master\neon\bin\Release\PublishOutput
.NOTE: Remember this path because in the next set of tasks, we need to attend to the Windows
Path
search path environment variable.Figure 5.15.
neon
Project: PublishOutout Folder
At this point, the neo-compiler
project has been built and published. The remaining tasks are to:
- Configure Windows
Path
search environment variable, and - Test that the
neon
transcompiler works properly with a Visual Studio NEO smart contract project.
-
To configure the
Path
environment variable, from the Windows start menu, enter "system" and select the System control panel app. In the left pane, clickAdvanced system settings
to display theSystem Properties
dialog box.Figure 5.16. Control Panel: System Properties
-
On the
System Properties
dialog box, clickEnvironment Variables...
to display theEnvironment Variables
dialog box. Note thePath
environment variable in the System variables section. SelectPath
and clckEdit...
.Figure 5.17. Control Panel: System Properties: Environment Variables
-
Click
New
to add the PublishOutput path to the current list of folders in thePath
environment variable. UseC:\NEO\neo-compiler-master\neo-compiler-master\neon\bin\Release\PublishOutput
for the value of the new path. ClickOK
twice to close the 2 Environment Variables dialog boxed and return the the System control panel app.Figure 5.18. Control Panel: System Properties:
Path
Environment Variable
-
We'll go step-by-step. Firt, open a new Windows Command Prompt. Enter
Path
and press Enter to inspect the current value of thePath
environment variable. You should be able to find the PublishOutput path in the list (closer to the end of the list but it isn't necessarily the very last element of the list).Figure 5.19. Command Prompt:
Path
Environment Variable -
Open Visual Studio 2017 to create a new NEO smart contract project.
Figure 5.20. Visual Studio 2017
-
Select
File
>New
>Project...
to open the New Project dialog box. SelectVisual C#
. SelectNeoContract
. ClickOK
to close this dialog box and create a new NeoContract solution and project in Visual Studio.Figure 5.21. Visual Studio: Create a New NeoContract Project
-
Visual Studio may take a few minutes to create the NeoContract project.
Figure 5.22. Visual Studio: Creating the NeoContract Project
-
Right-click on the NeoContract project folder and select
Build
. Note the highlighted messages in the Build section of the Output panel. These 2 message indicate the Visual Studio was able to create both the NEO virtual machine byte code file as well as the Application Binary Interace (ABI) file (in JSON format).NOTE: If you don't see these 2 messages, the most likely senarios are:
neon.dll
wasn't published properly. Go back to Task 6 of this activity.- The
Path
environment variable was not set correctly. Go back to Task 16 of this activity. - You had opened Visual Studio before you set the
Path
environment variable. Close Visual Studio and then go back to Task 20.
Figure 5.23. Visual Studio: Building the NeoContract Project
-
Open the neo-compiler project in Visual Studio by double-clicking
neo-gui.sln
in theC:\NEO\neo-gui-developer-master\neo-gui-developer-master
folder created in Activity 2 - Download and unpack NEO developer tool projects (source).Figure 5.24. Open
neo-gui.sln
in Visual Studio 2017 -
Uncheck the message
Ask me for every project in this solution
and clickOK
.Figure 5.25. Uncheck the message
Ask me for every project in this solution
and clickOK
-
Visual Studio will open with the project displayed in the Solution Explorer to the right.
Figure 5.26. Visual Studio: Solution Explorer
-
(OPTIONAL) If you are comfortable making code changes to a Windows C# .NET Webforms application, navigate to the
Mainform.cs
source file in theUI
folder. Right-click this file and selectView Code
. Scroll down to the MainForm() constructor method. At end of the constructor, add the highlighted single line of code:this.Text - "neo-gui-dev - " + Settings.Default.DataDirectoryPath;
Type
ctrl+s
to save your changes to this source file. This single line of code with display the blockchain database folder name in the app's title bar next to app's name. This is a useful practice when you're using multiple sets of JSON configuration files (more about these later).Figure 5.27. Optional source changes
-
Still in Visual Studio with the
neo-gui.sln
solution open (developer version), clickStart
to runneo-gui
with the Visual Studio debugger.Figure 5.28.
neo-gui
: Start with Visual Studio Debugger -
If this is the very first time you have worked with a NEO project, you may be prompted to install a root certificate into the Windows certificate store. Click
Yes
.Figure 5.29. Accept NEO Root Certificate
-
The
neo-gui
(developer version) app should open and begin syncing with the NEO testnet network. You should see the block counts in the bottom-right corner increase over time as well as the the green progress bar begin to animate. Click Wallet > Exit to close the Neo-Gui-Developer Node/Wallet app.Figure 5.30.
neo-gui
(Developer Version) App
The tasks for this activity are complete. Proceed to Activity 6 - Download, install, and test Docker platform.
- [NEOTUTORIAL] NEO Project, NEO smart contract tutorial from http://docs.neo.org/en-us/sc/tutorial.html
- [NEONCOMPILER] NEO Project, Neon NEO MSIL Transcompiler from https://github.com/neo-project/neo-compiler.
- [NEOGUIDEVWALLET] NEO Project, hNeo-Gui-Developer Node/Wallet from hhttps://github.com/CityOfZion/neo-gui-developer.