-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
Support for #define #1766
Comments
@jnm2 there are technical reasons why it does't currently work. This is due to code generation done for aliases behind the scenes. Have a look at this gist showing the difference between plain .cake snd what's passed to Roslyn. That said, there's no technical reason why we couldn't get it to work. But first, what is your use case? |
Cool! My use case is that I prefer Shouldn't be too hard to hoist #defines to the top then? |
I have a real use case now: avoiding Would you take a PR for this? |
If you like to submit a PR we'll review it. Tried this in csi.exe
it works there, so should work in Cake too, but it needs to come first in the file so these defines would need to be moved to top of script like using statements much similar to what I propose in #1854 . |
If it's fresh in your mind, would you do it? That would be perhaps more efficient. |
To spin this even further I’d say we should support defines via cmdline/config/environment (similar to |
@mholo65 #if (FOO)
#r ".\Newtonsoft.Json.dll"
#endif
Console.WriteLine(
Newtonsoft.Json.JsonConvert.SerializeObject(
new {
Hello = "World"
}
)
); and it works regardless if i define FOO or not, so would seem as I propose we first align with what Roslyn / csi.exe does as that's likely a fairly simple fix and later on look if we can / should improve it in any way. I do like the |
Submitted PR #1858 as a proposed fixed for this issue. |
Thank you @devlead! |
The Cake script
Causes:
(Version 0.21.1+Branch.main.Sha.9ff85bb53ea1890fabeb709d38ba79d3bf5cb16f)
Is there a technical reason this can't work or am I the first to try?
The text was updated successfully, but these errors were encountered: