diff --git a/containers/dart/.devcontainer/Dockerfile b/containers/dart/.devcontainer/Dockerfile index 527e428476..4119eb5bee 100644 --- a/containers/dart/.devcontainer/Dockerfile +++ b/containers/dart/.devcontainer/Dockerfile @@ -7,8 +7,6 @@ FROM google/dart:2 ENV PATH="$PATH":"/root/.pub-cache/bin" -RUN pub global activate webdev - # Install git, process tools RUN apt-get update && apt-get -y install git procps diff --git a/containers/dart/.devcontainer/devcontainer.json b/containers/dart/.devcontainer/devcontainer.json index a696913065..4996dd9b02 100644 --- a/containers/dart/.devcontainer/devcontainer.json +++ b/containers/dart/.devcontainer/devcontainer.json @@ -2,13 +2,12 @@ "name": "Dart", "dockerFile": "Dockerfile", "extensions": [ - "dart-code.dart-code", - "msjsdiag.debugger-for-chrome" + "dart-code.dart-code" ], // Uncomment the next line if you want to publish any ports. // "appPort": [], // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "pub get" + // "postCreateCommand": "" } diff --git a/containers/dart/.vscode/launch.json b/containers/dart/.vscode/launch.json index eed8622f79..6079d56a07 100644 --- a/containers/dart/.vscode/launch.json +++ b/containers/dart/.vscode/launch.json @@ -8,9 +8,13 @@ "name": "Launch Server", "type": "dart", "request": "launch", - "program": "server.dart", - "cwd": "${workspaceFolder}/test-project", - "preLaunchTask": "get" + "program": "bin/server.dart", + "cwd": "test-project", + "serverReadyAction": { + "pattern": "Listening on localhost:([0-9]+)", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } } ] } \ No newline at end of file diff --git a/containers/dart/.vscode/tasks.json b/containers/dart/.vscode/tasks.json deleted file mode 100644 index 458981e967..0000000000 --- a/containers/dart/.vscode/tasks.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "get", - "type": "shell", - "command": "cd test-project && pub get" - } - - ] -} \ No newline at end of file diff --git a/containers/dart/README.md b/containers/dart/README.md index 7ac13d4707..fe6873c082 100644 --- a/containers/dart/README.md +++ b/containers/dart/README.md @@ -38,11 +38,9 @@ This definition includes some test code that will help you verify it is working 2. Clone this repository. 3. Start VS Code, press F1, and select **Remote-Containers: Open Folder in Container...** 4. Select the `containers/dart` folder. -5. After the folder has opened in the container, press F5 to start the project. This will automatically run `pub get` and build the code before starting it. -6. Once the project is running, press F1 and select **Remote-Containers: Forward Port from Container...** -7. Select port 8080 and click the "Open Browser" button in the notification that appears. -8. You should see "Hello remote world!" after the page loads. -9. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. +5. After the folder has opened in the container, press F5 to start the project and launch the browser. +6. You should see "Hello remote world!" after the page loads. +7. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. ## License diff --git a/containers/dart/test-project/.gitignore b/containers/dart/test-project/.gitignore index 50602ac67e..03d22407c8 100644 --- a/containers/dart/test-project/.gitignore +++ b/containers/dart/test-project/.gitignore @@ -9,3 +9,6 @@ build/ # Directory created by dartdoc doc/api/ + +# Don't exclude bin/ folders for Dart projects +![Bb]in/ \ No newline at end of file diff --git a/containers/dart/test-project/analysis_options.yaml b/containers/dart/test-project/analysis_options.yaml deleted file mode 100644 index d5105e6f22..0000000000 --- a/containers/dart/test-project/analysis_options.yaml +++ /dev/null @@ -1,6 +0,0 @@ -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- - -include: package:pedantic/analysis_options.yaml diff --git a/containers/dart/test-project/server.dart b/containers/dart/test-project/bin/server.dart similarity index 63% rename from containers/dart/test-project/server.dart rename to containers/dart/test-project/bin/server.dart index 1b7512b58f..a6550a399e 100644 --- a/containers/dart/test-project/server.dart +++ b/containers/dart/test-project/bin/server.dart @@ -6,16 +6,11 @@ import 'dart:io'; Future main() async { - - - var server = await HttpServer.bind( + final server = await HttpServer.bind( InternetAddress.loopbackIPv4, 8080, ); - print('*************************************************************************'); - print('* Press F1, select "Remote-Containers: Forward Port from Container...", *'); - print('* and select the server port listed below to access server. *'); - print('*************************************************************************'); + print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { @@ -23,4 +18,4 @@ Future main() async { ..write('Hello remote world!') ..close(); } -} \ No newline at end of file +} diff --git a/containers/dart/test-project/pubspec.yaml b/containers/dart/test-project/pubspec.yaml index 5f3b44b037..ba55c0b6d3 100644 --- a/containers/dart/test-project/pubspec.yaml +++ b/containers/dart/test-project/pubspec.yaml @@ -8,8 +8,3 @@ description: A test project environment: sdk: '>=2.1.0 <3.0.0' - -dev_dependencies: - build_runner: ^1.1.2 - build_web_compilers: ^1.0.0 - pedantic: ^1.0.0