Unverified Commit 79ae04d4 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Build the solution on Windows (#33528)

Switch from building Runner.vcxproj to Runner.sln on Windows, to allow
for multiple-project builds (e.g., separate plugin projects).
parent 68841469
...@@ -615,6 +615,9 @@ class WindowsProject { ...@@ -615,6 +615,9 @@ class WindowsProject {
// The MSBuild project file. // The MSBuild project file.
File get vcprojFile => _editableDirectory.childFile('Runner.vcxproj'); File get vcprojFile => _editableDirectory.childFile('Runner.vcxproj');
// The MSBuild solution file.
File get solutionFile => _editableDirectory.childFile('Runner.sln');
/// The file where the VS build will write the name of the built app. /// The file where the VS build will write the name of the built app.
/// ///
/// Ideally this will be replaced in the future with inspection of the project. /// Ideally this will be replaced in the future with inspection of the project.
......
...@@ -38,16 +38,16 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {S ...@@ -38,16 +38,16 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {S
); );
final String configuration = buildInfo.isDebug ? 'Debug' : 'Release'; final String configuration = buildInfo.isDebug ? 'Debug' : 'Release';
final String projectPath = windowsProject.vcprojFile.path; final String solutionPath = windowsProject.solutionFile.path;
// Run the script with a relative path to the project using the enclosing // Run the script with a relative path to the project using the enclosing
// directory as the workingDirectory, to avoid hitting the limit on command // directory as the workingDirectory, to avoid hitting the limit on command
// lengths in batch scripts if the absolute path to the project is long. // lengths in batch scripts if the absolute path to the project is long.
final Process process = await processManager.start(<String>[ final Process process = await processManager.start(<String>[
buildScript, buildScript,
vcvarsScript, vcvarsScript,
fs.path.basename(projectPath), fs.path.basename(solutionPath),
configuration, configuration,
], workingDirectory: fs.path.dirname(projectPath)); ], workingDirectory: fs.path.dirname(solutionPath));
final Status status = logger.startProgress( final Status status = logger.startProgress(
'Building Windows application...', 'Building Windows application...',
timeout: null, timeout: null,
......
...@@ -25,7 +25,7 @@ void main() { ...@@ -25,7 +25,7 @@ void main() {
final MockPlatform windowsPlatform = MockPlatform() final MockPlatform windowsPlatform = MockPlatform()
..environment['PROGRAMFILES(X86)'] = r'C:\Program Files (x86)\'; ..environment['PROGRAMFILES(X86)'] = r'C:\Program Files (x86)\';
final MockPlatform notWindowsPlatform = MockPlatform(); final MockPlatform notWindowsPlatform = MockPlatform();
const String projectPath = r'C:\windows\Runner.vcxproj'; const String solutionPath = r'C:\windows\Runner.sln';
const String visualStudioPath = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'; const String visualStudioPath = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community';
const String vcvarsPath = visualStudioPath + r'\VC\Auxiliary\Build\vcvars64.bat'; const String vcvarsPath = visualStudioPath + r'\VC\Auxiliary\Build\vcvars64.bat';
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
testUsingContext('Windows build fails when there is no vcvars64.bat', () async { testUsingContext('Windows build fails when there is no vcvars64.bat', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
fs.file(projectPath).createSync(recursive: true); fs.file(solutionPath).createSync(recursive: true);
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'windows'] const <String>['build', 'windows']
), throwsA(isInstanceOf<ToolExit>())); ), throwsA(isInstanceOf<ToolExit>()));
...@@ -87,7 +87,7 @@ void main() { ...@@ -87,7 +87,7 @@ void main() {
testUsingContext('Windows build fails on non windows platform', () async { testUsingContext('Windows build fails on non windows platform', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
fs.file(projectPath).createSync(recursive: true); fs.file(solutionPath).createSync(recursive: true);
enableVcvarsMocking(); enableVcvarsMocking();
fs.file('pubspec.yaml').createSync(); fs.file('pubspec.yaml').createSync();
fs.file('.packages').createSync(); fs.file('.packages').createSync();
...@@ -103,7 +103,7 @@ void main() { ...@@ -103,7 +103,7 @@ void main() {
testUsingContext('Windows build invokes msbuild and writes generated files', () async { testUsingContext('Windows build invokes msbuild and writes generated files', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
fs.file(projectPath).createSync(recursive: true); fs.file(solutionPath).createSync(recursive: true);
enableVcvarsMocking(); enableVcvarsMocking();
fs.file('pubspec.yaml').createSync(); fs.file('pubspec.yaml').createSync();
fs.file('.packages').createSync(); fs.file('.packages').createSync();
...@@ -111,9 +111,9 @@ void main() { ...@@ -111,9 +111,9 @@ void main() {
when(mockProcessManager.start(<String>[ when(mockProcessManager.start(<String>[
r'C:\packages\flutter_tools\bin\vs_build.bat', r'C:\packages\flutter_tools\bin\vs_build.bat',
vcvarsPath, vcvarsPath,
fs.path.basename(projectPath), fs.path.basename(solutionPath),
'Release', 'Release',
], workingDirectory: fs.path.dirname(projectPath))).thenAnswer((Invocation invocation) async { ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async {
return mockProcess; return mockProcess;
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment