hoffi/gulp-msbuild

remove extra msbuild command line attributes

Closed this issue · 8 comments

In relations to issue #27 I am finding that the suggestion provided somewhat works.

When I try run this commend via Gulp

return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "project" },
            logCommand: true
            })
        );

The log command is:
xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

This does not actually publish the code.

I tied running this command directly into MSBuild on my PC:
msbuild project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

And it ERRORS out on the publish. I then manually modified the string and test again. I removed the target, verbosity, toolversion nologo manulaly and tried again.
msbuild project.sln /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

And it worked GREAT from the PC directly using msbuild.

So is there a way to remove the extra parameters from the command that is sent via your plugin?

i.e. I would like see if:
xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Build /verbosity:normal /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

is changed to this works:
xbuild /Users/sethk/Documents/workspace/project/project.sln /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

Thoughts?

hoffi commented

Hm in the current version it is not possible to remove the target, verbosity and toolsversion as i assumed they are needed always. You can remove the /nologo argument by setting nologo: true.

Isn't there a "Publish" target or something like that?

I am narrowing the issue to the LOGO parameter so I tried what you suggested.

gulp.task('msbuild', () => {
   return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "project" },
            logCommand: true,
            errorOnFail: true,
            stderr: true,
            stdout: false,
            verbosity: 'diagnostic',
            nologo: true
            })
        );
});

But the commend sent still has the logo
[14:15:30] Using MSBuild command: xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Rebuild /verbosity:diagnostic /toolsversion:4.0 /nologo /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

Can you confirm that the nologo:true removes it from the command?

hoffi commented

Argh my fault sorry. "nologo: false" of course

@hoffi Removing the logo helped but now my build is failing due to the toolsVersion. Any chance we can add a flag to that so it isn't sent via the command?

FYI
When I use toolsVersion: 'auto' I get NaN

xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Rebuild /verbosity:normal /toolsversion:NaN /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

hoffi commented

I have published a fix for toolsVersion: "auto", it will now fallback to 4.0 on mac.

I have also added the feature to explicitly pass undefined or null as toolsVersion to remove them in version 0.4.1, so this:

gulp.task('msbuild', () => {
   return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "project" },
            logCommand: true,
            errorOnFail: true,
            stderr: true,
            stdout: false,
            verbosity: 'diagnostic',
            nologo: true,
            toolsVersion: undefined // Add this line
            })
        );
});

should work for you.

Can you confirm?

That no longer errors my build out. Thank you! It still isn't doing the publish part but I will keep diving into it.

Just an an FYI. My build script below does the build but no publish.

gulp.task('msbuild', () => {
    return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "Project" },
            logCommand: true,
            nologo: false,
            toolsVersion: undefined 
            })
        );
});

Outputs:
xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Rebuild /verbosity:normal /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

When I run this in MSBuild on my PC it works as I want it too.

msbuild project.sln /target:Rebuild /verbosity:normal /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project

Thoughts

hoffi commented

No problem.
It could be that Mono doesn't understand this command. Maybe also try with targets: ['Publish']. But i have no other ideas.

Adding the targets results in this "MSBuild failed with code 1!"

[11:03:36] Starting 'msbuild'...
[11:03:36] Using MSBuild command: xbuild /Users/sethk/Documents/workspace/project/project.sln /target:Publish /verbosity:normal /property:Configuration=Debug /property:DeployOnBuild=true /property:PublishProfile=project
[11:03:36] MSBuild failed with code 1!
[11:03:36] Finished 'msbuild' after 607 ms
gulp.task('msbuild', () => {
    return gulp.src(config.env.build + '/project.sln')
        .pipe(msbuild({
            targets: ['Publish'],
            properties: {Configuration: 'Debug', DeployOnBuild: true, PublishProfile: "project" },
            logCommand: true,
            nologo: false,
            toolsVersion: undefined
            })
        );
});