hoffi / gulp-msbuild

gulp-msbuild has moved to https://github.com/fluffynuts/gulp-msbuild.
MIT License
53 stars 44 forks source link

Does this work for .Net Framework 4.6 version #37

Closed Shuliyey closed 8 years ago

Shuliyey commented 8 years ago

I don't seem to be able to find the VisualStudioVersion property option for the gulp-msbuild

Basicly my visual studio project is using .Net Framework 4.6, so the old msbuild.exe won't work. I have to use the new msbuild that's located at 'C:\Program Files (x86)\MSBUILD\14.0\Bin\MSBuild.exe'

By using this msbuild tool I can build my project successfully

D:\tfs_data\Dev\Development>where msbuild
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe

D:\tfs_data\Dev\Development>msbuild Fti.Infinity.sln /m /t:Build /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0

However I don't seem to be able to build my solution using gulp-msbuild. As I couldn't find a VisualStudioVersion property to pass to the gulp-msbuild module.

I get the below error

[16:17:56] Using gulpfile D:\tfs_data\Dev\Development\gulpfile.js
[16:17:56] Starting 'build'...
[16:17:56] Finished 'build' after 57 μs
[16:18:16] MSBuild failed with code 1!
Shuliyey commented 8 years ago

I believe the problem is here at lib/msbuild-finder.js

 var version = constants.MSBUILD_VERSIONS[options.toolsVersion];
  if (!version) {
    throw new PluginError(constants.PLUGIN_NAME, 'No MSBuild Version was supplied!');
  }

  var is64Bit = options.architecture === 'x64';

  if (version === '12.0' || version === '14.0') {
    // On 64-bit systems msbuild is always under the x86 directory. If this
    // doesn't exist we are on a 32-bit system. See also:
    // https://blogs.msdn.microsoft.com/visualstudio/2013/07/24/msbuild-is-now-part-of-visual-studio/
    var env_var_dir = process.env['ProgramFiles(x86)'] || process.env['ProgramFiles'];
    var pathRoot = env_var_dir || path.join('C:', is64Bit ? 'Program Files (x86)' : 'Program Files');

    var x64_dir = is64Bit ? 'amd64' : '';
    return path.join(pathRoot, 'MSBuild', version, 'Bin', x64_dir, 'MSBuild.exe');
  }

I believe we should be allowed specify the env_var_dir. Possibly being able to specify it as an option.

hoffi commented 8 years ago

Hm shouldn't it help to pass the correct toolsVersion and VisualStudioVersion-Property to gulp-msbuild? Like:

gulp_msbuild({
  toolsVersion: 14.0,
  properties: { VisualStudioVersion: 14.0 },
  targets: ["Build"]
});

This should use the MSBuild executable at C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe

Shuliyey commented 8 years ago

aah I see i will try again the architecture to be x86

I confused this with Platform property :sweat:

Shuliyey commented 8 years ago

@hoffi it worked :smile: thank you so much, this is embarassing, it was my bad i confused architecture option with the Platform property.

Thanks a lot for the help and open sourcing this great library :smile:

Shuliyey commented 8 years ago

closing this issue, my misunderstanding when using the library

Shuliyey commented 8 years ago

Just adding one note

I have to specify the VisualStudioVersion as a string :smile:

so it will be something like this

gulp_msbuild({
  toolsVersion: 14.0,
  properties: { VisualStudioVersion: '14.0' },
  targets: ["Build"]
});
hoffi commented 8 years ago

No problem :)