Skip to content
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

msbuild: init at 15.8 #50842

Merged
merged 0 commits into from Nov 23, 2018
Merged

msbuild: init at 15.8 #50842

merged 0 commits into from Nov 23, 2018

Conversation

leo60228
Copy link
Member

(recreation of #43680 because I broke my repo)

Motivation for this change

xbuild, which is part of Mono, is deprecated, in favor of the recently open-source MSBuild used on Windows. MSBuild has an incredibly complicated build system, which appears to fail silently on non-FHS systems. Thus, I used the official Ubuntu binaries. These require relatively little patching, as .NET is a bytecode language, so patchelf is not necessary. I don't have a Mac to test, but it may work on MacOS as well for this reason. This is definitely a stopgap; however, MSBuild's custom build system will require extensive work to be used, or even emulated, on NixOS. Since #43680, I've updated it to 15.8, cleaned up the build script, and shrunk the package by about 100MB.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@leo60228
Copy link
Member Author

Wait, I accidentally reverted the update.

@avnik
Copy link
Contributor

avnik commented Nov 20, 2018

Does it impossible to build it from source?

@leo60228
Copy link
Member Author

It uses a custom build process which automatically downloads pre-compiled Mono binaries.

@worldofpeace
Copy link
Contributor

I bit back I was looking at your original pr and applied some of @samueldr feedback.
Almost died in a stash but here it is 😄

diff --git a/pkgs/development/tools/build-managers/msbuild/default.nix b/pkgs/development/tools/build-managers/msbuild/default.nix
index 781f5b1c524..93d19fb047c 100644
--- a/pkgs/development/tools/build-managers/msbuild/default.nix
+++ b/pkgs/development/tools/build-managers/msbuild/default.nix
@@ -14,15 +14,21 @@ stdenv.mkDerivation rec {
   dontConfigure = true;
   dontBuild = true;
 
-  unpackPhase = "dpkg-deb -x $src .";
-  installPhase = ''
-    substituteInPlace usr/bin/msbuild --replace /usr/bin/mono ${mono}/bin/mono --replace /usr/lib/mono/msbuild/15.0/bin/MSBuild.dll '$(dirname $0)/../usr/lib/mono/msbuild/15.0/bin/MSBuild.dll'
+  unpackPhase = "dpkg-deb -x $src build";
+  installPhase = "
+    (
+    cd build
     mv usr/bin .
-    mkdir -p $out
-    cp -r ./bin ./usr $out
-    cp -rs ${mono}/lib/mono/msbuild/15.0/bin/Roslyn $out/usr/lib/mono/msbuild/15.0/bin/Roslyn
-    cp -rs ${mono}/lib/mono/4.5 $out/usr/lib/mono/4.5
-  '';
+    mv usr/lib .
+    rm -rf usr
+    )
+    cp -r build/ $out
+
+    substituteInPlace $out/bin/msbuild --replace /usr/bin/mono ${mono}/bin/mono --replace /usr/lib/mono/msbuild/15.0/bin/MSBuild.dll $out/lib/mono/msbuild/15.0/bin/MSBuild.dll
+
+    ln -s ${mono}/lib/mono/msbuild/15.0/bin/Roslyn $out/lib/mono/msbuild/15.0/bin/Roslyn
+    ln -s ${mono}/lib/mono/4.5 $out/lib/mono/4.5
+  ";
 
   meta = with stdenv.lib; {
     description = "The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio";

Main things addressed if I recall correctly were:

  • Symlink instead of copying stuff from mono
  • No usr in $out
  • Bring in the env-vars file

Also didn't include anything from share/doc/ because it didn't look useful.

@@ -76,6 +76,10 @@ stdenv.mkDerivation rec {
# [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in
+ ''
ln -s $out/bin/mcs $out/bin/gmcs
''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the previous pr:

Update on this: I cannot recall, but I believe (knowing me probably not) the upstream Mono maintainers told me to apply this. I completely forgot about this until yesterday, though, you might have to check.

I think we'd need a definitive answer on whether this is needed to merge this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good build machine. Could you see if it still runs without it?

@leo60228 leo60228 closed this Nov 23, 2018
@fpletz fpletz merged commit f5464f9 into NixOS:master Nov 23, 2018
@leo60228
Copy link
Member Author

Nice GitHub bug 😛 I'll create a new PR again, I guess.

@worldofpeace
Copy link
Contributor

worldofpeace commented Nov 26, 2018

@leo60228 #50842 (comment)

I don't have a good build machine. Could you see if it still runs without it?

I was actually able to reproduce what @jdanekrh mentioned in the older pr without this change.

I think I've encountered the same error also. When compiling a project, the compilation would fail with

  Microsoft.Common.CurrentVersion.targets(3446, 5): [MSB3491] Could not write lines to file "/Debug/ClientLib.csproj.CoreCompileInputs.cache". Could not find a part of the path "/Debug/ClientLib.csproj.CoreCompileInputs.cache".
  Microsoft.Common.CurrentVersion.targets(5101, 5): [MSB3191] Unable to create directory "/Debug/". Access to the path "/Debug/" is denied.

(it attempts to write to the filesystem root, because a prefix is not set correctly).

I resolved the same thing by 1) downloading msbuild and unpacking msbuild, 2) setting it in jetbrains.rider in GUI in Use custom MSBuild version to

/home/jdanek/Downloads/msbuild/MSBuild.dll

and 3) adding to my .bashrc the following

export MSBuildExtensionsPath=/home/jdanek/Downloads/msbuild/Extensions

It went away when I applied it IIRC.
I'll test your new pr, with the latest msbuild, and see if I can reproduce it again.

@Ekleog
Copy link
Member

Ekleog commented Dec 8, 2018

@leo60228 Have you opened your new PR already? If not, can you link to https://github.com/NixOS/nixpkgs/issues/29817 from it when you do it (preferably with some keyword like Closes #29817), so that it can close the issue automatically once it's merged? :)

@baracoder
Copy link
Contributor

😕 I am a bit confused, what is the state of msbuild? I can't find anything in master.

@worldofpeace
Copy link
Contributor

I'm not sure, @leo60228 do you still have the expression?
If you don't have enough time for it, it could still be there for someone to pick up.

It would improve the situation for getting source builds for applications that need msbuild dramatically, because we'd actually have it.

@leo60228
Copy link
Member Author

I still have it, but I don't have time for it. I'll try and push it later.

@betaboon
Copy link
Contributor

betaboon commented Apr 1, 2019

@leo60228 any progress or any chance of sharing that expressions so someone else can pick it up.
i too have the requirement for msbuild ;)

@billksun
Copy link
Contributor

@leo60228 I would love to get msbuild in too. That way I can use NixOS for work projects.

@jirkadanek
Copy link
Member

@billksun Just BTW, there is MSBuild 16 available in dotnet core. I have it at /nix/store/klwr9h00b25ws7g7wj2iasnvl3b63xa3-dotnet-sdk-2.2.203/sdk/2.2.203/MSBuild.dll and the Rider IDE is able to detect it and use it, My only issue regarding C# on NixOS is #55435, and that has a reasonable workaround.

@jirkadanek jirkadanek mentioned this pull request Aug 6, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants