From a1eb0605aef9116657ccba2f6bcb4b3c3942ee8d Mon Sep 17 00:00:00 2001 From: madhurig Date: Fri, 30 Mar 2018 17:03:24 -0400 Subject: [PATCH 1/2] Remove signing setup from Xamarin iOS task --- .../resources.resjson/en-US/resources.resjson | 26 +--- Tasks/XamariniOS/Tests/L0.ts | 54 ++++--- Tasks/XamariniOS/Tests/L0CleanBuild.ts | 23 ++- Tasks/XamariniOS/Tests/L0FallbackXbuild.ts | 50 +++++++ Tasks/XamariniOS/Tests/L0MSBuildDefault.ts | 8 -- Tasks/XamariniOS/Tests/L0MSBuildLocation.ts | 10 +- .../Tests/L0MultipleWildcardMatch.ts | 23 ++- Tasks/XamariniOS/Tests/L0NoWildcardMatch.ts | 23 ++- Tasks/XamariniOS/Tests/L0OneWildcardMatch.ts | 23 ++- Tasks/XamariniOS/Tests/L0SignWithFiles.ts | 120 ---------------- Tasks/XamariniOS/Tests/L0SignWithIds.ts | 16 ++- Tasks/XamariniOS/Tests/L0SkipNugetRestore.ts | 19 ++- Tasks/XamariniOS/task.json | 116 ++------------- Tasks/XamariniOS/task.loc.json | 132 ++---------------- Tasks/XamariniOS/xamarinios.ts | 89 ++---------- Tests-Legacy/L0/XamariniOS/_suite.ts | 75 ++-------- Tests-Legacy/L0/XamariniOS/response.json | 18 ++- .../L0/XamariniOS/responseNoToolsFound.json | 2 +- 18 files changed, 198 insertions(+), 629 deletions(-) create mode 100644 Tasks/XamariniOS/Tests/L0FallbackXbuild.ts delete mode 100644 Tasks/XamariniOS/Tests/L0SignWithFiles.ts diff --git a/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson b/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson index 1bb07864afbb..0c4a816e62ff 100644 --- a/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson @@ -3,6 +3,7 @@ "loc.helpMarkDown": "[More Information](https://go.microsoft.com/fwlink/?LinkID=613729)", "loc.description": "Build an iOS app with Xamarin on macOS", "loc.instanceNameFormat": "Build Xamarin.iOS solution $(solution)", + "loc.releaseNotes": "iOS signing setup has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", "loc.group.displayName.sign": "Signing & Provisioning", "loc.group.displayName.advanced": "Advanced", "loc.input.label.solution": "Solution", @@ -21,33 +22,14 @@ "loc.input.help.args": "Additional command line arguments that should be used to build.", "loc.input.label.cwd": "Working directory", "loc.input.help.cwd": "Working directory in which builds will run. When empty, the root of the repository is used.", - "loc.input.label.buildTool": "Build tool", - "loc.input.label.mdtoolLocation": "Build tool path", - "loc.input.help.mdtoolLocation": "Optionally supply the path to xbuild (the Xamarin Studio mono build tool) or MSBuild (the Visual Studio for Mac build tool). When empty, the default xbuild or MSBuild path is used.", - "loc.input.label.signMethod": "Override using", - "loc.input.help.signMethod": "If the build should use a signing or provisioning method that is different than the default, choose that method here. Choose 'File Contents' to use a P12 certificate and provisioning profile. Choose 'Identifiers' to retrieve signing settings from the default Keychain and pre-installed profiles. Leave the corresponding fields blank if you do not wish to override default build settings.", + "loc.input.label.buildToolLocation": "Build tool path", + "loc.input.help.buildToolLocation": "Optionally supply the path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", "loc.input.label.iosSigningIdentity": "Signing identity", - "loc.input.help.iosSigningIdentity": "Optionally override the signing identity that will be used to sign the build. If nothing is entered, the setting in the Xcode project will be used. You may need to select 'Unlock Default Keychain' if you use this option.", - "loc.input.label.unlockDefaultKeychain": "Unlock default keychain", - "loc.input.help.unlockDefaultKeychain": "Resolve \"User interaction is not allowed\" errors by unlocking the default keychain.", - "loc.input.label.defaultKeychainPassword": "Default keychain password", - "loc.input.help.defaultKeychainPassword": "Password to unlock the default keychain when that option is set.", + "loc.input.help.iosSigningIdentity": "Optionally override the signing identity that will be used to sign the build. If nothing is entered, the setting in the project will be used.", "loc.input.label.provProfileUuid": "Provisioning profile UUID", "loc.input.help.provProfileUuid": "Optional UUID of an installed provisioning profile to be used for this build.", - "loc.input.label.p12": "P12 certificate file", - "loc.input.help.p12": "Optional relative path to a PKCS12-formatted P12 certificate file containing a signing certificate to be used for this build.", - "loc.input.label.p12pwd": "P12 password", - "loc.input.help.p12pwd": "Password to the P12 certificate file, if specified. Use a build variable to encrypt this value.", - "loc.input.label.provProfile": "Provisioning profile file", - "loc.input.help.provProfile": "Optional relative path to a file containing the provisioning profile override to be used for this build.", - "loc.input.label.removeProfile": "Remove profile after build", - "loc.input.help.removeProfile": "Specifies that the contents of the provisioning profile file should be removed from the build agent after the build is complete. **Only enable this if you are running one agent per user.**", "loc.messages.SignIdNotFound": "Failed to find iOS signing identity. Verify the signing and provisioning information provided.", - "loc.messages.TempKeychainSetupFailed": "Failed to add the temporary keychain to the keychains search path.", - "loc.messages.ProvProfileDetailsNotFound": "Failed to find the details for provisioning profile: %s", "loc.messages.ProvProfileUUIDNotFound": "Failed to find provisioning profile UUID for provisioning profile: %s", - "loc.messages.TempKeychainDeleteFailed": "Failed to delete temporary keychain %s created during the build.", - "loc.messages.ProvProfileDeleteFailed": "Failed to delete the provisioning profile %s.", "loc.messages.XamariniOSSucceeded": "Xamarin.iOS task execution completed with no errors.", "loc.messages.XamariniOSFailed": "Xamarin.iOS task failed with error %s. For guidance on setting up the build definition, see https://go.microsoft.com/fwlink/?LinkId=760847.", "loc.messages.MSB_Build0": "Build {0}", diff --git a/Tasks/XamariniOS/Tests/L0.ts b/Tasks/XamariniOS/Tests/L0.ts index 4048373a7ef8..c73e0a0c2ccd 100644 --- a/Tasks/XamariniOS/Tests/L0.ts +++ b/Tasks/XamariniOS/Tests/L0.ts @@ -22,27 +22,9 @@ describe('XamariniOS L0 Suite', function () { tr.run(); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone ' + + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone ' + '/p:Codesignkey=testSignIdentity /p:CodesignProvision=testUUID'), - 'xbuild should have run with codesign for IDs'); - assert(tr.stderr.length === 0, 'should not have written to stderr'); - assert(tr.succeeded, 'task should have succeeded'); - - done(); - }); - - it('XamariniOS signing with files', function (done: MochaDone) { - this.timeout(2500); - - const tp = path.join(__dirname, 'L0SignWithFiles.js'); - const tr = new ttm.MockTestRunner(tp); - - tr.run(); - - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone ' + - '/p:CodesignKeychain=/user/build/_xamariniostasktmp.keychain ' + - '/p:Codesignkey=iPhone Developer: XamariniOS Tester (HE432Y3E2Q) /p:CodesignProvision=testuuid'), - 'xbuild should have run with codesigning with files'); + 'msbuild should have run with codesign for IDs'); assert(tr.stderr.length === 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -58,8 +40,8 @@ describe('XamariniOS L0 Suite', function () { tr.run(); assert(!tr.ran('/home/bin/nuget restore src/project.sln'), 'nuget restore should not have run'); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), - 'xbuild should have run'); + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), + 'msbuild should have run'); assert(tr.stderr.length === 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -74,11 +56,11 @@ describe('XamariniOS L0 Suite', function () { tr.run(); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean'), - 'xbuild /t:Clean should have run'); + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean'), + 'msbuild /t:Clean should have run'); assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'nuget restore should have run'); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), - 'xbuild should have run'); + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), + 'msbuild should have run'); assert(tr.stderr.length === 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -135,7 +117,7 @@ describe('XamariniOS L0 Suite', function () { assert(tr.warningIssues.length === 0, 'should not have issued any warnings'); assert(tr.errorIssues.length === 0, 'should not have produced any errors'); assert(tr.succeeded, 'task should have succeeded'); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone')); + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone')); done(); }); @@ -153,7 +135,7 @@ describe('XamariniOS L0 Suite', function () { assert(tr.warningIssues[0] === 'loc_mock_MultipleSolutionsFound src/1.sln'); assert(tr.errorIssues.length === 0, 'should not have produced any errors'); assert(tr.succeeded, 'task should have succeeded'); - assert(tr.ran('/home/bin/xbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone')); + assert(tr.ran('/home/bin/msbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone')); done(); }); @@ -174,4 +156,20 @@ describe('XamariniOS L0 Suite', function () { done(); }); + + it('XamariniOS fallback to xbuild when msbuild is not found', function (done: MochaDone) { + this.timeout(1000); + + const tp = path.join(__dirname, 'L0FallbackXbuild.js'); + const tr = new ttm.MockTestRunner(tp); + + tr.run(); + + assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), + 'xbuild should have run'); + assert(tr.stderr.length === 0, 'should not have written to stderr'); + assert(tr.succeeded, 'task should have succeeded'); + + done(); + }); }) \ No newline at end of file diff --git a/Tasks/XamariniOS/Tests/L0CleanBuild.ts b/Tasks/XamariniOS/Tests/L0CleanBuild.ts index 6183fba1c21a..c55e2fac3e4c 100644 --- a/Tasks/XamariniOS/Tests/L0CleanBuild.ts +++ b/Tasks/XamariniOS/Tests/L0CleanBuild.ts @@ -15,15 +15,8 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock let a: ma.TaskLibAnswers = { @@ -31,26 +24,30 @@ let a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" + }, + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "code": 0, + "stdout": "msbuild" }, "/home/bin/nuget restore src/project.sln": { "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" } }, "checkPath" : { "/user/build": true, - "/home/bin/xbuild": true, + "/home/bin/msbuild": true, "/home/bin/nuget": true, "src/project.sln": true }, diff --git a/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts b/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts new file mode 100644 index 000000000000..50f7c8420a4a --- /dev/null +++ b/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts @@ -0,0 +1,50 @@ + +import ma = require('vsts-task-lib/mock-answer'); +import tmrm = require('vsts-task-lib/mock-run'); +import path = require('path'); + +let taskPath = path.join(__dirname, '..', 'xamarinios.js'); +let tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); + +process.env['HOME']='/user/home'; //replace with mock of setVariable when task-lib has the support + +tr.setInput('solution', 'src/project.sln'); //path +tr.setInput('configuration', 'Release'); +tr.setInput('args', ''); +tr.setInput('packageApp', ''); //boolean +tr.setInput('forSimulator', ''); //boolean +tr.setInput('runNugetRestore', 'false'); //boolean +tr.setInput('iosSigningIdentity', ''); +tr.setInput('provProfileUuid', ''); + +// provide answers for task mock +let a: ma.TaskLibAnswers = { + "getVariable": { + "HOME": "/user/home" + }, + "which": { + "xbuild": "/home/bin/xbuild" + }, + "exec": { + "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "code": 0, + "stdout": "msbuild" + }, + "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "code": 0, + "stdout": "msbuild" + } + }, + "checkPath" : { + "/user/build": true, + "/home/bin/xbuild": true, + "src/project.sln": true + }, + "findMatch" : { + "src/project.sln": ["src/project.sln"] + } +}; +tr.setAnswers(a); + +tr.run(); + diff --git a/Tasks/XamariniOS/Tests/L0MSBuildDefault.ts b/Tasks/XamariniOS/Tests/L0MSBuildDefault.ts index b8fe041f19ec..c153959dd70d 100644 --- a/Tasks/XamariniOS/Tests/L0MSBuildDefault.ts +++ b/Tasks/XamariniOS/Tests/L0MSBuildDefault.ts @@ -15,16 +15,8 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean -tr.setInput('buildTool', 'msbuild'); // provide answers for task mock let a: ma.TaskLibAnswers = { diff --git a/Tasks/XamariniOS/Tests/L0MSBuildLocation.ts b/Tasks/XamariniOS/Tests/L0MSBuildLocation.ts index 862b0308571c..c0fdf4a1c25c 100644 --- a/Tasks/XamariniOS/Tests/L0MSBuildLocation.ts +++ b/Tasks/XamariniOS/Tests/L0MSBuildLocation.ts @@ -15,17 +15,9 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean -tr.setInput('buildTool', 'msbuild'); -tr.setInput('mdtoolLocation', '/home/bin/msbuild'); +tr.setInput('buildToolLocation', '/home/bin/msbuild'); // provide answers for task mock let a: ma.TaskLibAnswers = { diff --git a/Tasks/XamariniOS/Tests/L0MultipleWildcardMatch.ts b/Tasks/XamariniOS/Tests/L0MultipleWildcardMatch.ts index 41b7bcce2430..b15f1a30df7a 100644 --- a/Tasks/XamariniOS/Tests/L0MultipleWildcardMatch.ts +++ b/Tasks/XamariniOS/Tests/L0MultipleWildcardMatch.ts @@ -15,15 +15,8 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock const a: ma.TaskLibAnswers = { @@ -31,26 +24,30 @@ const a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { - "/home/bin/xbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" + }, + "/home/bin/msbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "code": 0, + "stdout": "msbuild" }, "/home/bin/nuget restore src/1.sln": { "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild src/1.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" } }, "checkPath": { "/user/build": true, - "/home/bin/xbuild": true, + "/home/bin/msbuild": true, "/home/bin/nuget": true, "**/*.sln": true }, diff --git a/Tasks/XamariniOS/Tests/L0NoWildcardMatch.ts b/Tasks/XamariniOS/Tests/L0NoWildcardMatch.ts index 0a11cbcb2f97..849dcc71cd5f 100644 --- a/Tasks/XamariniOS/Tests/L0NoWildcardMatch.ts +++ b/Tasks/XamariniOS/Tests/L0NoWildcardMatch.ts @@ -15,15 +15,8 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock const a: ma.TaskLibAnswers = { @@ -31,26 +24,30 @@ const a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" + }, + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "code": 0, + "stdout": "msbuild" }, "/home/bin/nuget restore src/project.sln": { "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" } }, "checkPath": { "/user/build": true, - "/home/bin/xbuild": true, + "/home/bin/msbuild": true, "/home/bin/nuget": true, "src/project.sln": true }, diff --git a/Tasks/XamariniOS/Tests/L0OneWildcardMatch.ts b/Tasks/XamariniOS/Tests/L0OneWildcardMatch.ts index 9ef88a78d15a..7ff8057e2fe9 100644 --- a/Tasks/XamariniOS/Tests/L0OneWildcardMatch.ts +++ b/Tasks/XamariniOS/Tests/L0OneWildcardMatch.ts @@ -15,15 +15,8 @@ tr.setInput('clean', 'true'); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock const a: ma.TaskLibAnswers = { @@ -31,26 +24,30 @@ const a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" + }, + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { + "code": 0, + "stdout": "msbuild" }, "/home/bin/nuget restore src/project.sln": { "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" } }, "checkPath": { "/user/build": true, - "/home/bin/xbuild": true, + "/home/bin/msbuild": true, "/home/bin/nuget": true, "**/*.sln": true }, diff --git a/Tasks/XamariniOS/Tests/L0SignWithFiles.ts b/Tasks/XamariniOS/Tests/L0SignWithFiles.ts deleted file mode 100644 index 88d67d6a41d8..000000000000 --- a/Tasks/XamariniOS/Tests/L0SignWithFiles.ts +++ /dev/null @@ -1,120 +0,0 @@ - -import ma = require('vsts-task-lib/mock-answer'); -import tmrm = require('vsts-task-lib/mock-run'); -import path = require('path'); - -let taskPath = path.join(__dirname, '..', 'xamarinios.js'); -let tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath); - -process.env['HOME']='/user/home'; //replace with mock of setVariable when task-lib has the support - -tr.setInput('solution', 'src/project.sln'); //path -tr.setInput('configuration', 'Release'); -tr.setInput('args', ''); -tr.setInput('packageApp', ''); //boolean -tr.setInput('forSimulator', ''); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', '/user/build/cert.p12'); //path -tr.setInput('p12pwd', 'p12password'); -tr.setInput('iosSigningIdentity', ''); -tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', '/user/build/testuuid.mobileprovision'); //path -tr.setInput('removeProfile', ''); //boolean -tr.setInput('cwd', '/user/build'); - -// provide answers for task mock -let a: ma.TaskLibAnswers = { - "getVariable": { - "HOME": "/user/home" - }, - "which": { - "xbuild": "/home/bin/xbuild", - "nuget": "/home/bin/nuget", - "security": "/usr/bin/security", - "/usr/libexec/PlistBuddy": "/usr/libexec/PlistBuddy", - "rm": "/bin/rm", - "cp": "/bin/cp" - }, - "exec": { - "/home/bin/nuget restore src/project.sln": { - "code": 0, - "stdout": "nuget restore" - }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /p:CodesignKeychain=/user/build/_xamariniostasktmp.keychain /p:Codesignkey=iPhone Developer: XamariniOS Tester (HE432Y3E2Q) /p:CodesignProvision=testuuid": { - "code": 0, - "stdout": "xbuild" - }, - "/usr/bin/security create-keychain -p _xamariniostask_TmpKeychain_Pwd#1 /user/build/_xamariniostasktmp.keychain" : { - "code": 0, - "stdout": "temporary keychain created" - }, - "/usr/bin/security set-keychain-settings -lut 7200 /user/build/_xamariniostasktmp.keychain": { - "code": 0, - "stdout": "set-keychain-settings on temporary keychain output" - }, - "/usr/bin/security unlock-keychain -p _xamariniostask_TmpKeychain_Pwd#1 /user/build/_xamariniostasktmp.keychain": { - "code": 0, - "stdout": "temporary keychain unlocked" - }, - "/usr/bin/security import /user/build/cert.p12 -P p12password -A -t cert -f pkcs12 -k /user/build/_xamariniostasktmp.keychain": { - "code": 0, - "stdout": "p12 imported into temporary keychain" - }, - "/usr/bin/security find-identity -v -p codesigning /user/build/_xamariniostasktmp.keychain" : { - "code": 0, - "stdout": "1) 5229BFC905F473E52FAD51208174528106966930 \"iPhone Developer: XamariniOS Tester (HE432Y3E2Q)\"\n 1 valid identities found" - }, - "/usr/bin/security cms -D -i /user/build/testuuid.mobileprovision": { - "code": 0, - "stdout": "prov profile details here" - }, - "/usr/libexec/PlistBuddy -c Print UUID _xcodetasktmp.plist": { - "code": 0, - "stdout": "testuuid" - }, - "/bin/rm -f _xcodetasktmp.plist": { - "code": 0, - "stdout": "delete output here" - }, - "/usr/bin/security list-keychain -d user" : { - "code": 0, - "stdout": "/User/test/Library/Keychains/login.keychain \n /user/build/_xamariniostasktmp.keychain" - }, - "/usr/bin/security list-keychain -d user -s /user/build/_xamariniostasktmp.keychain /User/test/Library/Keychains/login.keychain /user/build/_xamariniostasktmp.keychain": { - "code": 0, - "stdout": "list-keychain output here" - }, - "/bin/cp -f /user/build/testuuid.mobileprovision /user/home/Library/MobileDevice/Provisioning Profiles/testuuid.mobileprovision" : { - "code": 0, - "stdout": "provisioning profile copied" - } - }, - "checkPath" : { - "/user/build": true, - "/home/bin/xbuild": true, - "/home/bin/nuget": true, - "src/project.sln": true, - "/usr/bin/security": true, - "/usr/libexec/PlistBuddy": true, - "/bin/rm": true, - "/bin/cp": true - }, - "exist": { - "/user/build/cert.p12": true, - "/user/build/testuuid.mobileprovision": true - }, - "stats": { - "/user/build": { - "isFile": false - } - }, - "findMatch" : { - "src/project.sln": ["src/project.sln"] - } -}; -tr.setAnswers(a); - -tr.run(); - diff --git a/Tasks/XamariniOS/Tests/L0SignWithIds.ts b/Tasks/XamariniOS/Tests/L0SignWithIds.ts index 546ca66a5263..d4c5700a59d0 100644 --- a/Tasks/XamariniOS/Tests/L0SignWithIds.ts +++ b/Tasks/XamariniOS/Tests/L0SignWithIds.ts @@ -20,8 +20,6 @@ tr.setInput('p12', ''); //path tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', 'testSignIdentity'); tr.setInput('provProfileUuid', 'testUUID'); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock let a: ma.TaskLibAnswers = { @@ -29,23 +27,27 @@ let a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { + "/home/bin/msbuild /version /nologo": { + "code": 0, + "stdout": "15.1.0.0" + }, "/home/bin/nuget restore src/project.sln": { "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /p:Codesignkey=testSignIdentity /p:CodesignProvision=testUUID": { + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /p:Codesignkey=testSignIdentity /p:CodesignProvision=testUUID": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" } }, "checkPath" : { "/user/build": true, - "/home/bin/xbuild": true, - "/home/bin2/xbuild": true, + "/home/bin/msbuild": true, + "/home/bin2/msbuild": true, "/home/bin/nuget": true, "src/project.sln": true }, diff --git a/Tasks/XamariniOS/Tests/L0SkipNugetRestore.ts b/Tasks/XamariniOS/Tests/L0SkipNugetRestore.ts index c4fe4e6dda54..04e2e258a27f 100644 --- a/Tasks/XamariniOS/Tests/L0SkipNugetRestore.ts +++ b/Tasks/XamariniOS/Tests/L0SkipNugetRestore.ts @@ -14,15 +14,8 @@ tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'false'); //boolean -tr.setInput('signMethod', 'file'); -tr.setInput('unlockDefaultKeychain', ''); //boolean -tr.setInput('defaultKeychainPassword', ''); -tr.setInput('p12', ''); //path -tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); -tr.setInput('provProfile', ''); //path -tr.setInput('removeProfile', ''); //boolean // provide answers for task mock let a: ma.TaskLibAnswers = { @@ -30,18 +23,22 @@ let a: ma.TaskLibAnswers = { "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" + }, + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "code": 0, + "stdout": "msbuild" } }, "checkPath" : { "/user/build": true, - "/home/bin/xbuild": true, + "/home/bin/msbuild": true, "src/project.sln": true }, "findMatch" : { diff --git a/Tasks/XamariniOS/task.json b/Tasks/XamariniOS/task.json index a795e32e0ae5..7f78ad794e1e 100644 --- a/Tasks/XamariniOS/task.json +++ b/Tasks/XamariniOS/task.json @@ -10,10 +10,12 @@ ], "author": "Microsoft Corporation", "version": { - "Major": 1, - "Minor": 131, + "Major": 2, + "Minor": 133, "Patch": 0 }, + "preview": true, + "releaseNotes": "iOS signing setup has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", "demands": [ "Xamarin.iOS" ], @@ -76,7 +78,7 @@ "name": "runNugetRestore", "type": "boolean", "label": "Run NuGet restore", - "defaultValue": "true", + "defaultValue": "false", "required": true, "helpMarkDown": "Optionally run `nuget restore` on the Xamarin iOS solution to install all referenced packages before build. The 'nuget' tool in the PATH of the build agent machine will be used. To use a different version of NuGet or set additional arguments, use the [NuGet Installer Task](https://www.visualstudio.com/docs/build/steps/package/nuget-installer).", "groupName": "advanced" @@ -100,72 +102,24 @@ "groupName": "advanced" }, { - "name": "buildTool", - "aliases": [ "buildToolOption" ], - "type": "radio", - "label": "Build tool", - "required": false, - "groupName": "advanced", - "defaultValue": "xbuild", - "options": { - "xbuild": "xbuild (Xamarin Studio)", - "msbuild": "MSBuild (Visual Studio for Mac)" - } - }, - { - "name": "mdtoolLocation", - "aliases": [ "mdtoolFile" ], + "name": "buildToolLocation", + "aliases": [ "mdtoolFile", "mdtoolLocation" ], "type": "string", "label": "Build tool path", "defaultValue": "", "required": false, - "helpMarkDown": "Optionally supply the path to xbuild (the Xamarin Studio mono build tool) or MSBuild (the Visual Studio for Mac build tool). When empty, the default xbuild or MSBuild path is used.", + "helpMarkDown": "Optionally supply the path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", "groupName": "advanced" }, - { - "name": "signMethod", - "aliases": [ "signingOption" ], - "type": "radio", - "label": "Override using", - "required": false, - "groupName": "sign", - "defaultValue": "file", - "helpMarkDown": "If the build should use a signing or provisioning method that is different than the default, choose that method here. Choose 'File Contents' to use a P12 certificate and provisioning profile. Choose 'Identifiers' to retrieve signing settings from the default Keychain and pre-installed profiles. Leave the corresponding fields blank if you do not wish to override default build settings.", - "options": { - "file": "File Contents", - "id": "Identifiers" - } - }, + { "name": "iosSigningIdentity", "aliases": [ "signingIdentity" ], "type": "string", "label": "Signing identity", "required": false, - "helpMarkDown": "Optionally override the signing identity that will be used to sign the build. If nothing is entered, the setting in the Xcode project will be used. You may need to select 'Unlock Default Keychain' if you use this option.", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "unlockDefaultKeychain", - "aliases": [ "signingUnlockDefaultKeychain" ], - "type": "boolean", - "label": "Unlock default keychain", - "defaultValue": false, - "required": true, - "helpMarkDown": "Resolve \"User interaction is not allowed\" errors by unlocking the default keychain.", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "defaultKeychainPassword", - "aliases": [ "signingDefaultKeychainPassword" ], - "type": "string", - "label": "Default keychain password", - "required": false, - "helpMarkDown": "Password to unlock the default keychain when that option is set.", - "groupName": "sign", - "visibleRule": "signMethod = id" + "helpMarkDown": "Optionally override the signing identity that will be used to sign the build. If nothing is entered, the setting in the project will be used.", + "groupName": "sign" }, { "name": "provProfileUuid", @@ -174,49 +128,7 @@ "label": "Provisioning profile UUID", "required": false, "helpMarkDown": "Optional UUID of an installed provisioning profile to be used for this build.", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "p12", - "aliases": [ "signingP12File" ], - "type": "filePath", - "label": "P12 certificate file", - "required": false, - "helpMarkDown": "Optional relative path to a PKCS12-formatted P12 certificate file containing a signing certificate to be used for this build.", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "p12pwd", - "aliases": [ "signingP12Password" ], - "type": "string", - "label": "P12 password", - "required": false, - "helpMarkDown": "Password to the P12 certificate file, if specified. Use a build variable to encrypt this value.", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "provProfile", - "aliases": [ "signingProvisioningProfileFile" ], - "type": "filePath", - "label": "Provisioning profile file", - "required": false, - "helpMarkDown": "Optional relative path to a file containing the provisioning profile override to be used for this build.", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "removeProfile", - "aliases": [ "signingRemoveProfile" ], - "type": "boolean", - "label": "Remove profile after build", - "defaultValue": false, - "required": false, - "helpMarkDown": "Specifies that the contents of the provisioning profile file should be removed from the build agent after the build is complete. **Only enable this if you are running one agent per user.**", - "groupName": "sign", - "visibleRule": "signMethod = file" + "groupName": "sign" } ], "instanceNameFormat": "Build Xamarin.iOS solution $(solution)", @@ -228,11 +140,7 @@ }, "messages": { "SignIdNotFound": "Failed to find iOS signing identity. Verify the signing and provisioning information provided.", - "TempKeychainSetupFailed": "Failed to add the temporary keychain to the keychains search path.", - "ProvProfileDetailsNotFound": "Failed to find the details for provisioning profile: %s", "ProvProfileUUIDNotFound": "Failed to find provisioning profile UUID for provisioning profile: %s", - "TempKeychainDeleteFailed": "Failed to delete temporary keychain %s created during the build.", - "ProvProfileDeleteFailed": "Failed to delete the provisioning profile %s.", "XamariniOSSucceeded": "Xamarin.iOS task execution completed with no errors.", "XamariniOSFailed": "Xamarin.iOS task failed with error %s. For guidance on setting up the build definition, see https://go.microsoft.com/fwlink/?LinkId=760847.", "MSB_Build0" : "Build {0}", diff --git a/Tasks/XamariniOS/task.loc.json b/Tasks/XamariniOS/task.loc.json index 125e602dc899..45aae9c02859 100644 --- a/Tasks/XamariniOS/task.loc.json +++ b/Tasks/XamariniOS/task.loc.json @@ -10,10 +10,12 @@ ], "author": "Microsoft Corporation", "version": { - "Major": 1, - "Minor": 131, + "Major": 2, + "Minor": 133, "Patch": 0 }, + "preview": true, + "releaseNotes": "ms-resource:loc.releaseNotes", "demands": [ "Xamarin.iOS" ], @@ -80,7 +82,7 @@ "name": "runNugetRestore", "type": "boolean", "label": "ms-resource:loc.input.label.runNugetRestore", - "defaultValue": "true", + "defaultValue": "false", "required": true, "helpMarkDown": "ms-resource:loc.input.help.runNugetRestore", "groupName": "advanced" @@ -106,48 +108,18 @@ "groupName": "advanced" }, { - "name": "buildTool", - "aliases": [ - "buildToolOption" - ], - "type": "radio", - "label": "ms-resource:loc.input.label.buildTool", - "required": false, - "groupName": "advanced", - "defaultValue": "xbuild", - "options": { - "xbuild": "xbuild (Xamarin Studio)", - "msbuild": "MSBuild (Visual Studio for Mac)" - } - }, - { - "name": "mdtoolLocation", + "name": "buildToolLocation", "aliases": [ - "mdtoolFile" + "mdtoolFile", + "mdtoolLocation" ], "type": "string", - "label": "ms-resource:loc.input.label.mdtoolLocation", + "label": "ms-resource:loc.input.label.buildToolLocation", "defaultValue": "", "required": false, - "helpMarkDown": "ms-resource:loc.input.help.mdtoolLocation", + "helpMarkDown": "ms-resource:loc.input.help.buildToolLocation", "groupName": "advanced" }, - { - "name": "signMethod", - "aliases": [ - "signingOption" - ], - "type": "radio", - "label": "ms-resource:loc.input.label.signMethod", - "required": false, - "groupName": "sign", - "defaultValue": "file", - "helpMarkDown": "ms-resource:loc.input.help.signMethod", - "options": { - "file": "File Contents", - "id": "Identifiers" - } - }, { "name": "iosSigningIdentity", "aliases": [ @@ -157,33 +129,7 @@ "label": "ms-resource:loc.input.label.iosSigningIdentity", "required": false, "helpMarkDown": "ms-resource:loc.input.help.iosSigningIdentity", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "unlockDefaultKeychain", - "aliases": [ - "signingUnlockDefaultKeychain" - ], - "type": "boolean", - "label": "ms-resource:loc.input.label.unlockDefaultKeychain", - "defaultValue": false, - "required": true, - "helpMarkDown": "ms-resource:loc.input.help.unlockDefaultKeychain", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "defaultKeychainPassword", - "aliases": [ - "signingDefaultKeychainPassword" - ], - "type": "string", - "label": "ms-resource:loc.input.label.defaultKeychainPassword", - "required": false, - "helpMarkDown": "ms-resource:loc.input.help.defaultKeychainPassword", - "groupName": "sign", - "visibleRule": "signMethod = id" + "groupName": "sign" }, { "name": "provProfileUuid", @@ -194,57 +140,7 @@ "label": "ms-resource:loc.input.label.provProfileUuid", "required": false, "helpMarkDown": "ms-resource:loc.input.help.provProfileUuid", - "groupName": "sign", - "visibleRule": "signMethod = id" - }, - { - "name": "p12", - "aliases": [ - "signingP12File" - ], - "type": "filePath", - "label": "ms-resource:loc.input.label.p12", - "required": false, - "helpMarkDown": "ms-resource:loc.input.help.p12", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "p12pwd", - "aliases": [ - "signingP12Password" - ], - "type": "string", - "label": "ms-resource:loc.input.label.p12pwd", - "required": false, - "helpMarkDown": "ms-resource:loc.input.help.p12pwd", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "provProfile", - "aliases": [ - "signingProvisioningProfileFile" - ], - "type": "filePath", - "label": "ms-resource:loc.input.label.provProfile", - "required": false, - "helpMarkDown": "ms-resource:loc.input.help.provProfile", - "groupName": "sign", - "visibleRule": "signMethod = file" - }, - { - "name": "removeProfile", - "aliases": [ - "signingRemoveProfile" - ], - "type": "boolean", - "label": "ms-resource:loc.input.label.removeProfile", - "defaultValue": false, - "required": false, - "helpMarkDown": "ms-resource:loc.input.help.removeProfile", - "groupName": "sign", - "visibleRule": "signMethod = file" + "groupName": "sign" } ], "instanceNameFormat": "ms-resource:loc.instanceNameFormat", @@ -256,11 +152,7 @@ }, "messages": { "SignIdNotFound": "ms-resource:loc.messages.SignIdNotFound", - "TempKeychainSetupFailed": "ms-resource:loc.messages.TempKeychainSetupFailed", - "ProvProfileDetailsNotFound": "ms-resource:loc.messages.ProvProfileDetailsNotFound", "ProvProfileUUIDNotFound": "ms-resource:loc.messages.ProvProfileUUIDNotFound", - "TempKeychainDeleteFailed": "ms-resource:loc.messages.TempKeychainDeleteFailed", - "ProvProfileDeleteFailed": "ms-resource:loc.messages.ProvProfileDeleteFailed", "XamariniOSSucceeded": "ms-resource:loc.messages.XamariniOSSucceeded", "XamariniOSFailed": "ms-resource:loc.messages.XamariniOSFailed", "MSB_Build0": "ms-resource:loc.messages.MSB_Build0", diff --git a/Tasks/XamariniOS/xamarinios.ts b/Tasks/XamariniOS/xamarinios.ts index 5af106cba868..cab2514796fb 100644 --- a/Tasks/XamariniOS/xamarinios.ts +++ b/Tasks/XamariniOS/xamarinios.ts @@ -1,6 +1,5 @@ import path = require('path'); import tl = require('vsts-task-lib/task'); -import sign = require('ios-signing-common/ios-signing-common'); import msbuildhelpers = require('msbuildhelpers/msbuildhelpers'); import { ToolRunner } from 'vsts-task-lib/toolrunner'; @@ -45,26 +44,18 @@ async function run() { const runNugetRestore: boolean = tl.getBoolInput('runNugetRestore'); // find the build tool path based on the build tool and location inputs - const buildTool: string = tl.getInput('buildTool'); - const buildToolLocation: string = tl.getInput('mdtoolLocation', false); + const buildToolLocation: string = tl.getInput('buildToolLocation', false); let buildToolPath: string; if (buildToolLocation) { // location is specified buildToolPath = buildToolLocation; - if (buildTool === 'xbuild' && !buildToolLocation.toLowerCase().endsWith('xbuild')) { - buildToolPath = path.join(buildToolLocation, 'xbuild'); - } - if (buildTool === 'msbuild' && !buildToolLocation.toLowerCase().endsWith('msbuild')) { + if (buildToolLocation && !buildToolLocation.toLowerCase().endsWith('msbuild')) { buildToolPath = path.join(buildToolLocation, 'msbuild'); } } else { // no build tool path is supplied, check PATH - if (buildTool === 'msbuild') { - // check for msbuild 15 or higher, if not fall back to xbuild - buildToolPath = await msbuildhelpers.getMSBuildPath('15.0'); - } else { - buildToolPath = tl.which('xbuild', true); - } + // check for msbuild 15 or higher, if not fall back to xbuild + buildToolPath = await msbuildhelpers.getMSBuildPath('latest'); } tl.checkPath(buildToolPath, 'build tool'); tl.debug('Build tool path = ' + buildToolPath); @@ -97,52 +88,10 @@ async function run() { const workingDir: string = cwd || tl.getVariable('System.DefaultWorkingDirectory'); tl.cd(workingDir); - const signMethod: string = tl.getInput('signMethod', false); - let provProfileUUID: string = null; - let signIdentity: string = null; - - if (signMethod === 'file') { - let p12: string = tl.getPathInput('p12', false, false); - const p12pwd: string = tl.getInput('p12pwd', false); - const provProfilePath: string = tl.getPathInput('provProfile', false); - const removeProfile: boolean = tl.getBoolInput('removeProfile', false); - - if (tl.filePathSupplied('p12') && tl.exist(p12)) { - p12 = tl.resolve(cwd, p12); - tl.debug('cwd = ' + cwd); - const keychain: string = tl.resolve(cwd, '_xamariniostasktmp.keychain'); - const keychainPwd: string = '_xamariniostask_TmpKeychain_Pwd#1'; - - //create a temporary keychain and install the p12 into that keychain - tl.debug('installing cert in temp keychain'); - await sign.installCertInTemporaryKeychain(keychain, keychainPwd, p12, p12pwd, false); - codesignKeychain = keychain; - - //find signing identity - signIdentity = await sign.findSigningIdentity(keychain); - } - - //determine the provisioning profile UUID - if (tl.filePathSupplied('provProfile') && tl.exist(provProfilePath)) { - provProfileUUID = await sign.getProvisioningProfileUUID(provProfilePath); + let provProfileUUID: string = tl.getInput('provProfileUuid'); + let signIdentity: string = tl.getInput('iosSigningIdentity'); - if (removeProfile && provProfileUUID) { - profileToDelete = provProfileUUID; - } - } - } else if (signMethod === 'id') { - const unlockDefaultKeychain: boolean = tl.getBoolInput('unlockDefaultKeychain'); - const defaultKeychainPassword: string = tl.getInput('defaultKeychainPassword'); - if (unlockDefaultKeychain) { - const defaultKeychain: string = await sign.getDefaultKeychainPath(); - await sign.unlockKeychain(defaultKeychain, defaultKeychainPassword); - } - - signIdentity = tl.getInput('iosSigningIdentity'); - provProfileUUID = tl.getInput('provProfileUuid'); - } - - // Prepare xbuild build command line + // Prepare build command line const buildRunner: ToolRunner = tl.tool(buildToolPath); buildRunner.arg(solutionPath); buildRunner.argIf(configuration, '/p:Configuration=' + configuration); @@ -152,7 +101,7 @@ async function run() { buildRunner.line(args); } buildRunner.argIf(codesignKeychain, '/p:CodesignKeychain=' + codesignKeychain); - if (buildTool === 'msbuild' && signIdentity && signIdentity.indexOf(',') > 0) { + if (signIdentity && signIdentity.indexOf(',') > 0) { // Escape the input to workaround msbuild bug https://github.com/Microsoft/msbuild/issues/471 tl.debug('Escaping , in arg /p:Codesignkey to workaround msbuild bug.'); const signIdentityEscaped = signIdentity.replace(/[,]/g, '%2C'); @@ -170,27 +119,7 @@ async function run() { } catch (err) { tl.setResult(tl.TaskResult.Failed, tl.loc('XamariniOSFailed', err)); - } finally { - //clean up the temporary keychain, so it is not used to search for code signing identity in future builds - if (codesignKeychain) { - try { - await sign.deleteKeychain(codesignKeychain); - } catch (err) { - tl.debug('Failed to delete temporary keychain. Error = ' + err); - tl.warning(tl.loc('TempKeychainDeleteFailed', codesignKeychain)); - } - } - - //delete provisioning profile if specified - if (profileToDelete) { - try { - await sign.deleteProvisioningProfile(profileToDelete); - } catch (err) { - tl.debug('Failed to delete provisioning profile. Error = ' + err); - tl.warning(tl.loc('ProvProfileDeleteFailed', profileToDelete)); - } - } - } + } } run(); \ No newline at end of file diff --git a/Tests-Legacy/L0/XamariniOS/_suite.ts b/Tests-Legacy/L0/XamariniOS/_suite.ts index 7fc5ac14c470..11f238e7945c 100644 --- a/Tests-Legacy/L0/XamariniOS/_suite.ts +++ b/Tests-Legacy/L0/XamariniOS/_suite.ts @@ -32,22 +32,16 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('mdtoolLocation', ''); + tr.setInput('buildToolLocation', ''); tr.setInput('runNugetRestore', 'true'); //boolean - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'it should have run nuget restore'); - assert(tr.ran('/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run xbuild'); - assert(tr.invokedToolCount == 2, 'should have only run 2 commands'); + assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run msbuild'); + assert(tr.invokedToolCount == 3, 'should have only run 3 commands'); assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length == 0, 'should not have written to stderr'); assert(tr.succeeded, 'task should have succeeded'); @@ -58,7 +52,7 @@ describe('XamariniOS Suite', function() { }); }) - it('run XamariniOS with mdtoolLocation set', (done) => { + it('run XamariniOS with buildToolLocation set', (done) => { setResponseFile('response.json'); var tr = new trm.TaskRunner('XamariniOS', true, true); @@ -69,22 +63,15 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('buildTool', 'xbuild'); - tr.setInput('mdtoolLocation', '/home/bin2/'); + tr.setInput('buildToolLocation', '/home/bin2/'); tr.setInput('runNugetRestore', 'true'); //boolean - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'it should have run nuget restore'); - assert(tr.ran('/home/bin2/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run xbuild'); + assert(tr.ran('/home/bin2/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run msbuild'); assert(tr.invokedToolCount == 2, 'should have only run 2 commands'); assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length == 0, 'should not have written to stderr'); @@ -107,15 +94,9 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('mdtoolLocation', ''); - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); + tr.setInput('buildToolLocation', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { @@ -142,15 +123,9 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('mdtoolLocation', ''); - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); + tr.setInput('buildToolLocation', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { @@ -166,7 +141,7 @@ describe('XamariniOS Suite', function() { }); }) - it('fails when xbuildLocation not provided and xbuild is not found', (done) => { + it('fails when msbuildLocation not provided and msbuild is not found', (done) => { setResponseFile('responseNoToolsFound.json'); var tr = new trm.TaskRunner('XamariniOS', true, true); @@ -177,15 +152,9 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('mdtoolLocation', ''); - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); + tr.setInput('buildToolLocation', ''); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { @@ -193,7 +162,7 @@ describe('XamariniOS Suite', function() { assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length > 0, 'should have written to stderr'); assert(tr.failed, 'task should have failed'); - assert(tr.stderr.indexOf('not found xbuild: null') >= 0, 'wrong error message'); + assert(tr.stderr.indexOf('Xamarin.iOS task failed with error MSBuild or xbuild (Mono) were not found on the macOS or Linux agent') >= 0, 'wrong error message'); done(); }) .fail((err) => { @@ -201,7 +170,7 @@ describe('XamariniOS Suite', function() { }); }) - it('fails when xbuildLocation is provided but is incorrect', (done) => { + it('fails when msbuildLocation is provided but is incorrect', (done) => { setResponseFile('response.json'); var tr = new trm.TaskRunner('XamariniOS', true, true); @@ -212,16 +181,9 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('buildTool', 'xbuild'); - tr.setInput('mdtoolLocation', '/user/bin/'); - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); + tr.setInput('buildToolLocation', '/user/bin/'); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { @@ -229,7 +191,7 @@ describe('XamariniOS Suite', function() { assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length > 0, 'should have written to stderr'); assert(tr.failed, 'task should have failed'); - assert(tr.stderr.indexOf('not found build tool: /user/bin/xbuild') >= 0, 'wrong error message'); + assert(tr.stderr.indexOf('not found build tool: /user/bin/msbuild') >= 0, 'wrong error message'); done(); }) .fail((err) => { @@ -249,17 +211,10 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('buildTool', 'xbuild'); - tr.setInput('mdtoolLocation', '/home/bin2'); tr.setInput('runNugetRestore', 'true'); //boolean - tr.setInput('unlockDefaultKeychain', ''); //boolean - tr.setInput('defaultKeychainPassword', ''); - tr.setInput('p12', ''); //path - tr.setInput('p12pwd', ''); + tr.setInput('buildToolLocation', '/home/bin2'); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); - tr.setInput('provProfile', ''); //path - tr.setInput('removeProfile', ''); //boolean tr.run() .then(() => { diff --git a/Tests-Legacy/L0/XamariniOS/response.json b/Tests-Legacy/L0/XamariniOS/response.json index a2023f4fdb0a..256666e7bba3 100644 --- a/Tests-Legacy/L0/XamariniOS/response.json +++ b/Tests-Legacy/L0/XamariniOS/response.json @@ -3,7 +3,7 @@ "HOME": "/user/home" }, "which": { - "xbuild": "/home/bin/xbuild", + "msbuild": "/home/bin/msbuild", "nuget": "/home/bin/nuget" }, "exec": { @@ -11,18 +11,22 @@ "code": 0, "stdout": "nuget restore" }, - "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild /version /nologo": { "code": 0, - "stdout": "xbuild" + "stdout": "15.1.0.0" }, - "/home/bin2/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "xbuild" + "stdout": "msbuild" + }, + "/home/bin2/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { + "code": 0, + "stdout": "msbuild" } }, "checkPath": { - "/home/bin/xbuild": true, - "/home/bin2/xbuild": true, + "/home/bin/msbuild": true, + "/home/bin2/msbuild": true, "/home/bin/nuget": true, "src/project.sln": true }, diff --git a/Tests-Legacy/L0/XamariniOS/responseNoToolsFound.json b/Tests-Legacy/L0/XamariniOS/responseNoToolsFound.json index 4c5f7bc5256b..f9ebe8ee51e3 100644 --- a/Tests-Legacy/L0/XamariniOS/responseNoToolsFound.json +++ b/Tests-Legacy/L0/XamariniOS/responseNoToolsFound.json @@ -3,7 +3,7 @@ "HOME": "/user/home" }, "checkPath": { - "/home/bin2/xbuild": true, + "/home/bin2/msbuild": true, "src/project.sln": true }, "findMatch": { From 6ef844fdc54e02c7d8707f0e1852f13ecf79ead2 Mon Sep 17 00:00:00 2001 From: madhurig Date: Mon, 2 Apr 2018 15:18:43 -0400 Subject: [PATCH 2/2] PR feedback --- .../resources.resjson/en-US/resources.resjson | 4 ++-- Tasks/XamariniOS/Tests/L0FallbackXbuild.ts | 4 ++-- Tasks/XamariniOS/task.json | 4 ++-- Tasks/XamariniOS/xamarinios.ts | 12 ++---------- Tests-Legacy/L0/XamariniOS/_suite.ts | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson b/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson index 0c4a816e62ff..1108ac492024 100644 --- a/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/XamariniOS/Strings/resources.resjson/en-US/resources.resjson @@ -3,7 +3,7 @@ "loc.helpMarkDown": "[More Information](https://go.microsoft.com/fwlink/?LinkID=613729)", "loc.description": "Build an iOS app with Xamarin on macOS", "loc.instanceNameFormat": "Build Xamarin.iOS solution $(solution)", - "loc.releaseNotes": "iOS signing setup has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", + "loc.releaseNotes": "iOS signing set up has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", "loc.group.displayName.sign": "Signing & Provisioning", "loc.group.displayName.advanced": "Advanced", "loc.input.label.solution": "Solution", @@ -23,7 +23,7 @@ "loc.input.label.cwd": "Working directory", "loc.input.help.cwd": "Working directory in which builds will run. When empty, the root of the repository is used.", "loc.input.label.buildToolLocation": "Build tool path", - "loc.input.help.buildToolLocation": "Optionally supply the path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", + "loc.input.help.buildToolLocation": "Optionally supply the full path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", "loc.input.label.iosSigningIdentity": "Signing identity", "loc.input.help.iosSigningIdentity": "Optionally override the signing identity that will be used to sign the build. If nothing is entered, the setting in the project will be used.", "loc.input.label.provProfileUuid": "Provisioning profile UUID", diff --git a/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts b/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts index 50f7c8420a4a..5089fe67de65 100644 --- a/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts +++ b/Tasks/XamariniOS/Tests/L0FallbackXbuild.ts @@ -28,11 +28,11 @@ let a: ma.TaskLibAnswers = { "exec": { "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone /t:Clean": { "code": 0, - "stdout": "msbuild" + "stdout": "xbuild" }, "/home/bin/xbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone": { "code": 0, - "stdout": "msbuild" + "stdout": "xbuild" } }, "checkPath" : { diff --git a/Tasks/XamariniOS/task.json b/Tasks/XamariniOS/task.json index 7f78ad794e1e..e5f999ef5183 100644 --- a/Tasks/XamariniOS/task.json +++ b/Tasks/XamariniOS/task.json @@ -15,7 +15,7 @@ "Patch": 0 }, "preview": true, - "releaseNotes": "iOS signing setup has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", + "releaseNotes": "iOS signing set up has been removed from the task. Use `Secure Files` with supporting tasks `Install Apple Certificate` and `Install Apple Provisioning Profile` to setup signing. Updated options to work better with `Visual Studio for Mac`.", "demands": [ "Xamarin.iOS" ], @@ -108,7 +108,7 @@ "label": "Build tool path", "defaultValue": "", "required": false, - "helpMarkDown": "Optionally supply the path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", + "helpMarkDown": "Optionally supply the full path to MSBuild (the Visual Studio for Mac build tool). When empty, the default MSBuild path is used.", "groupName": "advanced" }, diff --git a/Tasks/XamariniOS/xamarinios.ts b/Tasks/XamariniOS/xamarinios.ts index cab2514796fb..5b3cb64cca4f 100644 --- a/Tasks/XamariniOS/xamarinios.ts +++ b/Tasks/XamariniOS/xamarinios.ts @@ -25,9 +25,6 @@ function expandSolutionWildcardPatterns(solutionPattern: string): string { } async function run() { - let codesignKeychain: string; - let profileToDelete: string; - try { tl.setResourcePath(path.join(__dirname, 'task.json')); @@ -47,11 +44,7 @@ async function run() { const buildToolLocation: string = tl.getInput('buildToolLocation', false); let buildToolPath: string; if (buildToolLocation) { - // location is specified buildToolPath = buildToolLocation; - if (buildToolLocation && !buildToolLocation.toLowerCase().endsWith('msbuild')) { - buildToolPath = path.join(buildToolLocation, 'msbuild'); - } } else { // no build tool path is supplied, check PATH // check for msbuild 15 or higher, if not fall back to xbuild @@ -88,8 +81,8 @@ async function run() { const workingDir: string = cwd || tl.getVariable('System.DefaultWorkingDirectory'); tl.cd(workingDir); - let provProfileUUID: string = tl.getInput('provProfileUuid'); - let signIdentity: string = tl.getInput('iosSigningIdentity'); + const provProfileUUID: string = tl.getInput('provProfileUuid'); + const signIdentity: string = tl.getInput('iosSigningIdentity'); // Prepare build command line const buildRunner: ToolRunner = tl.tool(buildToolPath); @@ -100,7 +93,6 @@ async function run() { if (args) { buildRunner.line(args); } - buildRunner.argIf(codesignKeychain, '/p:CodesignKeychain=' + codesignKeychain); if (signIdentity && signIdentity.indexOf(',') > 0) { // Escape the input to workaround msbuild bug https://github.com/Microsoft/msbuild/issues/471 tl.debug('Escaping , in arg /p:Codesignkey to workaround msbuild bug.'); diff --git a/Tests-Legacy/L0/XamariniOS/_suite.ts b/Tests-Legacy/L0/XamariniOS/_suite.ts index 11f238e7945c..61e65e927e4d 100644 --- a/Tests-Legacy/L0/XamariniOS/_suite.ts +++ b/Tests-Legacy/L0/XamariniOS/_suite.ts @@ -63,7 +63,7 @@ describe('XamariniOS Suite', function() { tr.setInput('args', ''); tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean - tr.setInput('buildToolLocation', '/home/bin2/'); + tr.setInput('buildToolLocation', '/home/bin2/msbuild'); tr.setInput('runNugetRestore', 'true'); //boolean tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', ''); @@ -191,7 +191,7 @@ describe('XamariniOS Suite', function() { assert(tr.resultWasSet, 'task should have set a result'); assert(tr.stderr.length > 0, 'should have written to stderr'); assert(tr.failed, 'task should have failed'); - assert(tr.stderr.indexOf('not found build tool: /user/bin/msbuild') >= 0, 'wrong error message'); + assert(tr.stderr.indexOf('not found build tool: /user/bin/') >= 0, 'wrong error message'); done(); }) .fail((err) => { @@ -212,7 +212,7 @@ describe('XamariniOS Suite', function() { tr.setInput('packageApp', ''); //boolean tr.setInput('forSimulator', ''); //boolean tr.setInput('runNugetRestore', 'true'); //boolean - tr.setInput('buildToolLocation', '/home/bin2'); + tr.setInput('buildToolLocation', '/home/bin2/msbuild'); tr.setInput('iosSigningIdentity', ''); tr.setInput('provProfileUuid', '');