-
Notifications
You must be signed in to change notification settings - Fork 43
CSharpCodeProvider doesn't support other then Web projects #38
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
Comments
Another issue (though I'm not sure that it depends on a project type) is that csc.exe isn't copied into output folder so runtime compilation doesn't work - it fails with error System.IO.DirectoryNotFoundException: Could not find a part of the path 'my-unittest-project\bin\Debug\net461\bin\roslyn\csc.exe'. I do see that
but there's no roslyn\csc.exe in the output. It seems that the same problem that in #13. But it's closed (as solved). But I have 1.0.8 where csc.exe still isn't copied to output. |
@evil-shrike thanks for the feedback. We recently made some change to make the provider work on non-web project. Would you like to give it a try? You can get the package from the feed below. Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -Version 1.0.9 -Source https://www.myget.org/F/roslyncodedomprovider/api/v3/index.json |
I met the same problem with 1.0.8, and I use with 1.0.9 but met with the error as follows:
actually, the roslyn csc path should be I solve it with code as follows: //Set hardcoded environment variable to set the path to the library
Environment.SetEnvironmentVariable("ROSLYN_COMPILER_LOCATION", System.IO.Directory.GetCurrentDirectory() + "\\roslyn", EnvironmentVariableTarget.Process);
var provider = new Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider();
//Clean up
Environment.SetEnvironmentVariable("ROSLYN_COMPILER_LOCATION", null, EnvironmentVariableTarget.Process); |
While I'm here, check the typo: |
Also, is this supported on a Mac? Current logic suggests Windows only and we've been getting a ton of complaints from users of VSMac that try building projects that use the https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package. |
@KirillOsenkov good catch. Will fix that typo. For now, the package only supports windows. If we get enough user requests, we may add that support. What's your use case on Mac? |
VSMac is getting a lot of reports that projects using this package fail to build on a mac :) I’m not sure what those projects are or what the usage is. |
@WeihanLi Looked into you project and the issue you saw is caused by the fact that PackageReference mode ignores install.xdt in the nupkg. To workaround the issue, you can add the following appSetting into your app.config file(no need to use environment variable).
|
@Jinhuafei Thank you so much. I've a few questions.
|
#1 yes, it supports windows relative path. You can use something like below. And it is interpreted as relative to the current working directory. BTW, ~ is not windows relative.
#2 The default value is [working directory]\bin\roslyn |
Thank you @Jinhuafei |
2.0.0-preview is released. After upgrading Microsoft.CodeDom.Providers.DotNetCompilerPlatform nupkg, please remember to uninstall Microsoft.Net.Compilers nupkg in your project. |
Can you add a method to |
@Jinhuafei Thanks. That's very helpful. Two related questions:
|
|
I understand that RoslynCodeDomProvider is part of ASP.NET ecosystem. But it's presented as a provider for CodeDom. Even package name has nothing to do with asp.net -
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
. So it seems totally legit to expect that CSharpCodeProvider will work in non ASP.NET projects, right?But it doesn't.
Rebuilding a solution where
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
package is installed in one of projects results in error MSB4044: The "KillProcess" task was not given a value for the required parameter "ImagePath".Double click on the error leads to
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props
:It seems that the issue can be fixed by addint Condition to KillProcess task:
The text was updated successfully, but these errors were encountered: