6
votes

When I try to build my SSDT project with MSBUILD, I get the following error

error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found

In my ...\MSBuild\Microsoft\VisualStudio folder, however, I only have V12.0, V14.0 and V15.0. SSDT is found only in V14.0.

How can I make sure MSBuild looks for includes in the right place?

2
I have exactly the same problem. In my case the build of the SSDT project worked with VS2017 RC and even with the VS2017 Release version on March 7 (build 26228.04). But since the last VS2017 update on March 14, 2017 (build 26228.09) I get the same error. If I change the .sln of the SSDT project to use VisualStudioVersion = 15.0.26228.9 I get this error instead: MSB4132: The tools version "15.0" is unrecognized. Available tools versions are "12.0", "14.0", "2.0", "3.5", "4.0". I really hope that somebody has a solution for this. (Maybe it's fixed "automagically" in the next VS2017 update.)haindl
Just an additional hint that may help: If you're using the MSBuild classes (like ProjectCollection) programmatically and not via the command line, you have to copy the redirected assembly versions from MSBuild to the .config of your application. Just go to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config and copy the whole <runtime> element in your .config. (And maybe also change the file paths in the Workaround section.) This tells MSBuild to use version 15 instead of something older. (At least this worked with the VS2017 Relase.)haindl

2 Answers

6
votes

Looks like the .Net 4.0 msbuild.exe was the wrong one to use.

The problem was solved by using msbuild.exe from the msbuild folder instead of the .Net folder.

%ProgramFiles(x86)%\msbuild\14.0\Bin
0
votes

If the code is cordova, try this:

Microsoft.VisualStudio.WJProject.Default.props cannot be found. error MSB4019

Enter in the platform/windows/cordova/lib, open the msbuildtools with notepad, and edit this part:

var versions = ['15.0', '14.0', '12.0', '4.0'];

with your versions you have.

For example will remove the 15 and 14 in the two functions

var versions = ['12.0', '4.0'];

and remove the || versions[2] || versions[3] in this line

var msbuildTools = versions[0] || versions[1] || versions[2] || versions[3];
module.exports.findAvailableVersion = function () {
var versions = ['15.0', '14.0', '12.0', '4.0'];

    return Q.all(versions.map(checkMSBuildVersion)).then(function (versions) {
        // select first msbuild version available, and resolve promise with it
        var msbuildTools = versions[0] || versions[1] || versions[2] || versions[3];

        return msbuildTools ? Q.resolve(msbuildTools) : Q.reject('MSBuild tools not found');
    });
};

function findAllAvailableVersionsFallBack() {
    var versions = ['15.0', '14.0', '12.0', '4.0'];
    events.emit('verbose', 'Searching for available MSBuild versions...');

    return Q.all(versions.map(checkMSBuildVersion)).then(function(unprocessedResults) {
        return unprocessedResults.filter(function(item) {
            return !!item;
        });
    });
}