-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow neon to compile from the source (2x) #142
Conversation
I'll need to take a look at this. We have other changes to the compiler (#144 as well as the temporary neon-de fork that I'm not sure how we are going to replicate going C# -> AVM directly. |
@devhawk Some ut was wrong and fixed, please take a look |
Can you copy your |
Sorry, I've got it wrong. projDefinition has no problem, but I found.
|
Thanks @nicolegys , could you test it again please? (If works we should port this change to 3x) |
Has this been tested with https://github.com/neo-project/neo-debugger? The screen shot above shows the .avmdbgnfo file getting created, so that's a good sign |
var log = new DefLogger(); | ||
log.Log("Neo.Compiler.MSIL console app v" + Assembly.GetEntryAssembly().GetName().Version); | ||
|
||
// Check argmuents | ||
if (args.Length == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a library for command line processing? neo-express uses https://github.com/natemcmaster/CommandLineUtils and I've been pretty happy with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we don't have a lot of arguments, only a file name, was discarded in other PR
7364563
if (args.Length == 0) | ||
{ | ||
log.Log("You need a parameter to specify the DLL or the file name of the project."); | ||
log.Log("Examples: "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also support single .cs files right?
We should have a --help option
looks good, a few pieces of minor feedback. I want to test to make sure it also fixes #78 before I sign off |
I tried creating a contract from template and compiling it with neon built out of this PR branch and it didn't work: C:\Users\harry\Source\neo\seattle\samples\hello2 > dotnet new neo-contract
The template "Neo Smart Contract" was created successfully.
C:\Users\harry\Source\neo\seattle\samples\hello2 > neon .\hello2.csproj
Neo.Compiler.MSIL console app v2.6.0.0
Compiling from csproj project
Unhandled exception. System.IO.FileNotFoundException: Could not find file 'C:\Users\harry\Source\neo\seattle\samples\hello2\Neo.SmartContract.Framework.dll'.
File name: 'C:\Users\harry\Source\neo\seattle\samples\hello2\Neo.SmartContract.Framework.dll'
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
at Neo.Compiler.Compiler.<>c.<CreateReferences>b__6_0(String u) in C:\Users\harry\Source\neo\official\devpack-dotnet\Neo.Compiler.MSIL\Compiler.cs:line 195
at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
at Neo.Compiler.Compiler.CreateReferences(String[] references) in C:\Users\harry\Source\neo\official\devpack-dotnet\Neo.Compiler.MSIL\Compiler.cs:line 195
at Neo.Compiler.Compiler.CompileCSFile(String[] filenames, String[] references, Boolean releaseMode) in C:\Users\harry\Source\neo\official\devpack-dotnet\Neo.Compiler.MSIL\Compiler.cs:line 175
at Neo.Compiler.Compiler.CompileCSProj(String filename, Boolean releaseMode) in C:\Users\harry\Source\neo\official\devpack-dotnet\Neo.Compiler.MSIL\Compiler.cs:line 77
at Neo.Compiler.Program.Main(String[] args) in C:\Users\harry\Source\neo\official\devpack-dotnet\Neo.Compiler.MSIL\Program.cs:line 105 |
Neo.Compiler.MSIL/Program.cs
Outdated
default: | ||
{ | ||
log.Log("File format not supported by neon: " + path); | ||
Environment.Exit(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, should just return -1 instead of using environment exit
<PackageReference Include="Neo.VM" Version="2.4.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a good idea. Today, the Neo.SmartContract.Framework versions independently from NEON. With this change, the version of Neo.SmartContract.Framework is hardcoded into the compiler.
Unfortunately, it appears this is the change that allows NEON to compile dlls on build instead of publish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was decided in 3x to include it to facilitate developers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't embed Neo.SmartContract.Framework in neon
FYI, I have an idea on how to locate the Neo.SmartContract.Framework assembly at runtime. The Microsoft.Extensions.DependencyModel nuget package can be used to parse the .deps.json file that is generated by Then with Cecil, we can build a custom assembly resolver that uses the DependencyModel information to resolve assemblies (deferring to cecil's DefaultAssemblyResolver for assemblies that aren't listed in the DependencyModel). We'd still have to figure out how to resolve the Neo.SmartContract.Framework package for compile from source. Honestly, I'm OK with having an embedded version of the Neo.SmartContract.Framework assembly in NEON as long as it's only used for compile from source scenarios. |
Could you try again, I think that was fixed here ee1aa41 |
As you can see in the thread of #131 all was agree in include in neon |
This is probably not as big a deal as I thought it was. We don't add new services in the blockchain very often and framework changes like FeaturesAttribute require a new version of the compiler anyway. |
Close #78
Port of #131 to 2x