-
Notifications
You must be signed in to change notification settings - Fork 588
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
[dotnet-fake] msbuild doesn't work within dotnet-fake because of MSBUILD_EXE_PATH #1776
Comments
Ok travis seems to have a similar behavior. When using
While the exact same commands work in "full" fake (https://travis-ci.org/fsprojects/FSharp.Formatting/builds/337219438?utm_source=github_status&utm_medium=notification)
I guess when running in |
The difference between --- fake_run.txt 2018-02-04 16:09:55.899220100 +0100
+++ dotnet_fake_run.txt 2018-02-04 16:10:02.430051700 +0100
@@ -1,4 +1,4 @@
-$ fake run myscript.fsx
+$ dotnet fake run myscript.fsx
loading dependencies ...
'ACLOCAL_PATH' -> 'C:\Program Files\Git\mingw64\share\aclocal;C:\Program Files\Git\usr\share\aclocal'
'ALLUSERSPROFILE' -> 'C:\ProgramData'
@@ -6,7 +6,7 @@
'ANSICON_DEF' -> '7'
'APPDATA' -> 'C:\Users\matth\AppData\Roaming'
'CLINK_DIR' -> 'C:\Program Files (x86)\clink\0.4.8'
-'COMMONPROGRAMFILES' -> 'C:\Program Files (x86)\Common Files'
+'COMMONPROGRAMFILES' -> 'C:\Program Files\Common Files'
'COMPUTERNAME' -> 'DESKTOP-FQBAN56'
'COMSPEC' -> 'C:\Windows\system32\cmd.exe'
'CONFIG_SITE' -> 'C:/Program Files/Git/mingw64/etc/config.site'
@@ -54,6 +54,7 @@
'MINGW_CHOST' -> 'x86_64-w64-mingw32'
'MINGW_PACKAGE_PREFIX' -> 'mingw-w64-x86_64'
'MINGW_PREFIX' -> 'C:/Program Files/Git/mingw64'
+'MSBUILD_EXE_PATH' -> 'C:\Program Files\dotnet\sdk\2.1.4\MSBuild.dll'
'MSYSTEM' -> 'MINGW64'
'MSYSTEM_CARCH' -> 'x86_64'
'MSYSTEM_CHOST' -> 'x86_64-w64-mingw32'
@@ -70,12 +71,11 @@
'PATHEXT' -> '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
'PKG_CONFIG_PATH' -> 'C:\Program Files\Git\mingw64\lib\pkgconfig;C:\Program Files\Git\mingw64\share\pkgconfig'
'PLINK_PROTOCOL' -> 'ssh'
-'PROCESSOR_ARCHITECTURE' -> 'x86'
-'PROCESSOR_ARCHITEW6432' -> 'AMD64'
+'PROCESSOR_ARCHITECTURE' -> 'AMD64'
'PROCESSOR_IDENTIFIER' -> 'Intel64 Family 6 Model 158 Stepping 9, GenuineIntel'
'PROCESSOR_LEVEL' -> '6'
'PROCESSOR_REVISION' -> '9e09'
-'PROGRAMFILES' -> 'C:\Program Files (x86)'
+'PROGRAMFILES' -> 'C:\Program Files'
'PS1' -> '\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
'PSModulePath' -> 'C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules'
'PUBLIC' -> 'C:\Users\Public'
@@ -98,4 +98,4 @@
'USERNAME' -> 'matth'
'USERPROFILE' -> 'C:\Users\matth'
'WINDIR' -> 'C:\Windows'
-'_' -> 'C:/ProgramData/chocolatey/bin/fake'
\ No newline at end of file
+'_' -> 'C:/Program Files/dotnet/dotnet'
\ No newline at end of file retrieved with seq { for d in System.Environment.GetEnvironmentVariables() do let de = d :?> System.Collections.DictionaryEntry in yield (de.Key.ToString(), de.Value.ToString()) }
|> Seq.sortBy fst
|> Seq.iter (fun (key, value) -> printfn "'%O' -> '%O'" key value) The |
The following workaround at the start of the build script seems to work: // Workaround https://github.com/fsharp/FAKE/issues/1776
System.Environment.SetEnvironmentVariable("MSBUILD_EXE_PATH", null) I verified that this workaround indeed works by checking that fsprojects/FSharp.Formatting@ec73945 is green as well. |
Question now is: Is this a fake or a dotnet-sdk bug? |
I have asked the core-developers about this: https://github.com/dotnet/cli/issues/8530 |
for reference, omnisharp and a few other tools reset both This environment variable may also be set when doing the inverse and trying to set up a build environment with custom msbuild locations.. Not sure what's a bug or feature here (.net cli, fake, msbuild,..), but the safe way is always to either use the msbuild version of |
Is another instance of this. |
@dasMulli thanks a lot I'll add that logic to FAKE, interesting that we never have noticed this in all the years. I hope that we don't have some users who want to set those environment variables.... This will be impossible/hard with any patch in FAKE. |
Would this prevent me from using Mono's MsBuild through FAKE? |
@cdrnet Are you setting one of these Environment variables by hand? |
in the library for FSAC, i do the same, resetting msbuild vars but that's because i explicit invoke msbuild tools. FSAC need to add a config for that too, atm use probably you can just add a setting to:
|
Ok thanks, so in addition to the change we can add an option to the msbuild parameters in FAKE. This way even if it breaks someone there is a workaround. |
…s provides a workaround for setting MSBUILD_EXE_PATH and MSBuildExtensionPath if neded (see #1776)
Sorry for commenting on a closed issue but I'm still able to reproduce this issue while building f sharp project with netcoreapp2.0 as target framework. All FAKE libraries updated to 5.0.0-beta014. Only maual reset of MSBUILD_EXE_PATH to null helps e.g. System.Environment.SetEnvironmentVariable("MSBuildExtensionsPath", null) as the step before calling MsBuild.Run. Thanks. |
Maybe I failed somewhere? |
@volaticus Can you tell me how I can reproduce this? |
Nevermind, these are different vars |
I think the problem is in module Fake.Core.Process with the removeEnvironmentVariable method. |
@volaticus Yes, thanks I kind of failed there :/ |
After trying a bunch of different implementation and looking at https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs I think the only reasonable way is a breaking change in the Process Module by changing Everything boils down to: Currently the Process module doesn't support this use-case. |
I even experimented with type EnvironmentVariableState =
| SetEnvironmentVariable of string
| UnsetEnvironmentVariable
type ProcStartInfo = {
Environment : Map<string, EnvironmentVariableState > } |
How would the user code look like for type ProcStartInfo = {
Environment : Map<string, string > }
let upd (psi:ProcStartInfo) =
{ psi with
Environment =
(psi.Environment)
|> Map.add "foo" "bar"
|> Map.add "x" "y"
|> Map.add "a" "b"
} I guess it isn't too bad ... But the danger is that people will create a new map with just their new values, instead of updating the existing map. |
Either that or let upd (psi:ProcStartInfo) =
psi
|> Process.setEnvironmentVariable "foo" "bar"
|> Process.setEnvironmentVariable "x" "y"
|> Process.setEnvironmentVariable "a" "b" or let upd (psi:ProcStartInfo) =
psi
|> Process.setEnvironmentVariables [ "foo","bar"; "x","y"; "a","b" ] |
I'm not sure I like it myself, but what do you think of type ProcStartInfo = {
Environment : (Map<string, string> -> Map<string, string>) option }
let upd (psi:ProcStartInfo) =
{ psi with
Environment = Some (fun env ->
env
|> Map.add "foo" "bar"
|> Map.add "x" "y"
|> Map.add "a" "b")
} ? At least it would be (imo) pretty obvious that this is an update operation, not a replacement. |
Therefore, my next suggestion will be 3bdf101 |
type ProcStartInfo = {
Environment : (Map<string, string> -> Map<string, string>) option }
let upd (psi:ProcStartInfo) =
{ psi with
Environment = Some (fun env ->
env
|> Map.add "foo" "bar"
|> Map.add "x" "y"
|> Map.add "a" "b")
} My problem with that is that we have too much callbacks here, The |
nah, I guess you are right. I was just thinking about ways to make it obvious to the user that they need to update it, not replace it. |
I added a comment to not set this field directly but use the helper methods ... |
At least it will probably fail relatively early if there is no temp, no path, etc |
Or - wild suggestion - check a few predefined (by windows) env variables, and throw if they are missing. E.g., check if the Map contains at least path and temp. If both are missing, don't even Process.Start, just fail hard. |
We could maybe add some hidden default variable (which is ignored later) and check if that one is still set :) |
@matthid yeah, looks good. So, if I, as a user, want to reuse the dotnet-cli MSBuild, I would
If you wanted to keep source-compatibility, you could keep the old Property, but make it Obsolete. |
No that wouldn't work as the path is |
Currently you would use |
run |
I think this is finally fixed now with beta015. Note that beta015 has a broken |
Wow this is coming back again for the |
Description
I just got some weird build-errors when trying to use
dotnet-fake
as dotnet-cli tool on AppVeyor. Maybe it was because of dotnet-sdk version issues or something else:fsprojects/FSharp.Formatting#460
Repro steps
Run fsprojects/FSharp.Formatting@e5901e7 on AppVeyor (https://ci.appveyor.com/project/matthid/fsharp-formatting-32np3/build/1.0.75).
Edit: The error was
which indicates maybe some dotnet-cli stuff was overwritten/broken (as the working version executes exactly same command, see https://ci.appveyor.com/project/matthid/fsharp-formatting-32np3/build/1.0.69 for example).
The text was updated successfully, but these errors were encountered: