-
-
Notifications
You must be signed in to change notification settings - Fork 985
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
Migrate from MSBuild to Roslyn #149
Comments
@AndreyAkinshin To be honest it sounds great! The only disadvantage I see right now is .NET 4.5+ support which means that we have to drop .NET 4.0 support. But on the other hand this should not be a big deal since most people that write benchmarks know that each .NET framework release brings performance updates and they are up to date. I am going to spend few hours at the airports tomorrow and think more about this! |
Yes, you need installed .NET 4.5 (or mono) but only for compiling. You still can target your benchmark methods to .NET 4.0. |
Yeah I like this idea, it's the approach that I originally took with MiniBench before I stopped that and started working with you on BenchmarkDotNet. I agree with @adamsitnik, the only issue I can see is that it forces people to have .NET 4.5 when building the benchmarks, but as he says, that's probably only a small amt of users. BTW you should take a look at CodeGenerator.cs, it's using Roslyn directly, but should give you some ideas. |
Wouldn't you like to also take a dependency on a MSBuild nuget package while at it? Or is xbuild now considered safe enough? |
@damageboy, I don't want to have the MSBuild dependency. I want to compile |
Understood, so you want to abolish the current build generators and go straight to the compiler? |
I think, we will keep current toolchain system. We should just write another Builder (e.g. |
One small request while we're changing this: could we give the generated C# files a different extension? If the runner is killed while executing tests, the C# code stays behind, which then confuses |
Yes, I think we need a separate issue for this feature. |
Filed #192. |
I have tried 3 different approaches. Here are some results: Approach 1Add a NuGet reference to Microsoft.Net.Compilers and use Advantages
Disadvantages
Approach 2Bundle csc.exe and its dependencies as resources files in BDN. (Currently implemented in the Advantages
Disadvantages
Approach 3Add a NuGet reference to Microsoft.CodeAnalysis.CSharp and compile Advantages
var compilation = CSharpCompilation
.Create("Program.dll")
.AddReferences(
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location))
.AddSyntaxTrees(tree); Disadvantages
SummaryI spent a lot of time with the approaches 1 and 2. Unfortunately, I failed, it is too hard to solve described problems and possible solutions include a lot of hacks, ugly code, and magic strings. For now, only the approach 3 makes sense to me: we need to upgrade BDN to .NET4.5 and add a reference to the Microsoft.CodeAnalysis.CSharp package. @mattwarren, @adamsitnik, what do you think? P.S. @adamsitnik, am I right, that with .NET4.5 we can drop portability tools and use the same Reflection API on the Full Framework and CoreCLR? |
#3 is the best |
@AndreyAkinshin I totally agree with you, #3 is the best for me, I can implement it right away Is that ok if I still create script for compilation but with call to csc.exe (no abasolute path)?
I am not sure, will verify that. |
Ok, great. |
@AndreyAkinshin Ok, it's done. And it is much more faster now (for my PC running all classic tests went from 250s to 70s)! I have also removed the portability api for reflection. It should also work with Mono, because I use same predefined assemblies as the host process. But you need to verify that ;/ |
Awesome! Can you also investigate, why do we have a failed build? |
Problem
Currently
ClassicBuilder
uses a combination ofBuildManager.DefaultBuildManager
andBuildBenchmark.bat
for project building. There are a lot of troubles with this approach:Suggestion
There is a cool NuGet package Microsoft.Net.Compilers which contains full Roslyn compiler (
csc.exe
+ additional dll files). Yep, it is a dependency, but It is not too terrible. Benefits of the suggested approach:@adamsitnik, @mattwarren, what do you think?
The text was updated successfully, but these errors were encountered: