├── .github
├── dependabot.yml
└── workflows
│ ├── build.yml
│ ├── release.yml
│ └── run-ui-tests.yml
├── .gitignore
├── .run
├── Run IDE for UI Tests.run.xml
├── Run IDE with Plugin.run.xml
├── Run Plugin Tests.run.xml
└── Run Plugin Verification.run.xml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle.kts
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── plugins-screen.png
├── run-configuration-running.png
└── run-configuration-settings.png
├── settings.gradle.kts
└── src
└── main
├── kotlin
└── org
│ └── jetbrains
│ └── advocates
│ └── rider
│ └── plugins
│ └── dotnetwatch
│ ├── DotNetWatchBundle.kt
│ ├── DotNetWatchIcons.kt
│ └── run
│ ├── DotNetWatchRunConfiguration.kt
│ ├── DotNetWatchRunConfigurationEditor.kt
│ ├── DotNetWatchRunConfigurationFactory.kt
│ ├── DotNetWatchRunConfigurationOptions.kt
│ ├── DotNetWatchRunConfigurationProducer.kt
│ ├── DotNetWatchRunConfigurationType.kt
│ ├── DotNetWatchRunConfigurationViewModel.kt
│ └── DotNetWatchVerbosity.kt
└── resources
├── META-INF
├── plugin.xml
└── pluginIcon.svg
├── icons
└── runConfiguration.svg
└── messages
└── DotNetWatchBundle.properties
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Dependabot configuration:
2 | # https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
3 |
4 | version: 2
5 | updates:
6 | # Maintain dependencies for Gradle dependencies
7 | - package-ecosystem: "gradle"
8 | directory: "/"
9 | target-branch: "next"
10 | schedule:
11 | interval: "daily"
12 | # Maintain dependencies for GitHub Actions
13 | - package-ecosystem: "github-actions"
14 | directory: "/"
15 | target-branch: "next"
16 | schedule:
17 | interval: "daily"
18 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2 | # - validate Gradle Wrapper,
3 | # - run test and verifyPlugin tasks,
4 | # - run buildPlugin task and prepare artifact for the further tests,
5 | # - run IntelliJ Plugin Verifier,
6 | # - create a draft release.
7 | #
8 | # Workflow is triggered on push and pull_request events.
9 | #
10 | # Docs:
11 | # - GitHub Actions: https://help.github.com/en/actions
12 | # - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action
13 | #
14 | ## JBIJPPTPL
15 |
16 | name: Build
17 | on:
18 | # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
19 | push:
20 | branches: [main]
21 | # Trigger the workflow on any pull request
22 | pull_request:
23 |
24 | jobs:
25 |
26 | # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
27 | gradleValidation:
28 | name: Gradle Wrapper
29 | runs-on: ubuntu-latest
30 | steps:
31 |
32 | # Check out current repository
33 | - name: Fetch Sources
34 | uses: actions/checkout@v2.3.4
35 |
36 | # Validate wrapper
37 | - name: Gradle Wrapper Validation
38 | uses: gradle/wrapper-validation-action@v1.0.4
39 |
40 | # Run verifyPlugin and test Gradle tasks
41 | test:
42 | name: Test
43 | needs: gradleValidation
44 | runs-on: ubuntu-latest
45 | steps:
46 |
47 | # Check out current repository
48 | - name: Fetch Sources
49 | uses: actions/checkout@v2.3.4
50 |
51 | # Setup Java 17 environment for the next steps
52 | - name: Setup Java
53 | uses: actions/setup-java@v2
54 | with:
55 | distribution: zulu
56 | java-version: 17
57 | check-latest: true
58 | cache: gradle
59 |
60 | # Set environment variables
61 | - name: Export Properties
62 | id: properties
63 | shell: bash
64 | run: |
65 | PROPERTIES="$(./gradlew properties --console=plain -q)"
66 | IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
67 |
68 | echo "::set-output name=ideVersions::$IDE_VERSIONS"
69 | echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
70 |
71 | # Cache Plugin Verifier IDEs
72 | - name: Setup Plugin Verifier IDEs Cache
73 | uses: actions/cache@v2.1.6
74 | with:
75 | path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
76 | key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
77 |
78 | # Run tests
79 | - name: Run Tests
80 | run: ./gradlew test
81 |
82 | # Run verifyPlugin Gradle task
83 | # - name: Verify Plugin
84 | # run: ./gradlew verifyPlugin
85 |
86 | # Run IntelliJ Plugin Verifier action using GitHub Action
87 | # - name: Run Plugin Verifier
88 | # run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
89 |
90 | # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
91 | # Requires test job to be passed
92 | build:
93 | name: Build
94 | needs: test
95 | runs-on: ubuntu-latest
96 | outputs:
97 | version: ${{ steps.properties.outputs.version }}
98 | changelog: ${{ steps.properties.outputs.changelog }}
99 | steps:
100 |
101 | # Check out current repository
102 | - name: Fetch Sources
103 | uses: actions/checkout@v2.3.4
104 |
105 | # Setup Java 17 environment for the next steps
106 | - name: Setup Java
107 | uses: actions/setup-java@v2
108 | with:
109 | distribution: zulu
110 | java-version: 17
111 | check-latest: true
112 | cache: gradle
113 |
114 | # Set environment variables
115 | - name: Export Properties
116 | id: properties
117 | shell: bash
118 | run: |
119 | PROPERTIES="$(./gradlew properties --console=plain -q)"
120 | VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
121 | NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
122 | CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
123 | CHANGELOG="${CHANGELOG//'%'/'%25'}"
124 | CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
125 | CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
126 |
127 | echo "::set-output name=version::$VERSION"
128 | echo "::set-output name=name::$NAME"
129 | echo "::set-output name=changelog::$CHANGELOG"
130 |
131 | # Build artifact using buildPlugin Gradle task
132 | - name: Build Plugin
133 | run: ./gradlew buildPlugin
134 |
135 | # Store built plugin as an artifact for downloading
136 | - name: Upload artifacts
137 | uses: actions/upload-artifact@v2.2.4
138 | with:
139 | name: "${{ steps.properties.outputs.name }} - ${{ steps.properties.outputs.version }}"
140 | path: ./build/distributions/*
141 |
142 | # Prepare a draft release for GitHub Releases page for the manual verification
143 | # If accepted and published, release workflow would be triggered
144 | releaseDraft:
145 | name: Release Draft
146 | if: github.event_name != 'pull_request'
147 | needs: build
148 | runs-on: ubuntu-latest
149 | steps:
150 |
151 | # Check out current repository
152 | - name: Fetch Sources
153 | uses: actions/checkout@v2.3.4
154 |
155 | # Remove old release drafts by using the curl request for the available releases with draft flag
156 | - name: Remove Old Release Drafts
157 | env:
158 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159 | run: |
160 | gh api repos/{owner}/{repo}/releases \
161 | --jq '.[] | select(.draft == true) | .id' \
162 | | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
163 |
164 | # Create new release draft - which is not publicly visible and requires manual acceptance
165 | - name: Create Release Draft
166 | env:
167 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168 | run: |
169 | gh release create v${{ needs.build.outputs.version }} \
170 | --draft \
171 | --title "v${{ needs.build.outputs.version }}" \
172 | --notes "${{ needs.build.outputs.changelog }}"
173 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | # GitHub Actions Workflow created for handling the release process based on the draft release prepared
2 | # with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
3 |
4 | name: Release
5 | on:
6 | release:
7 | types: [prereleased, released]
8 |
9 | jobs:
10 |
11 | # Prepare and publish the plugin to the Marketplace repository
12 | release:
13 | name: Publish Plugin
14 | runs-on: ubuntu-latest
15 | steps:
16 |
17 | # Check out current repository
18 | - name: Fetch Sources
19 | uses: actions/checkout@v2.3.4
20 | with:
21 | ref: ${{ github.event.release.tag_name }}
22 |
23 | # Setup Java 17 environment for the next steps
24 | - name: Setup Java
25 | uses: actions/setup-java@v2
26 | with:
27 | distribution: zulu
28 | java-version: 17
29 | cache: gradle
30 |
31 | # Update Unreleased section with the current release note
32 | - name: Patch Changelog
33 | run: |
34 | ./gradlew patchChangelog --release-note="`cat << EOM
35 | ${{ github.event.release.body }}
36 | EOM`"
37 |
38 | # Publish the plugin to the Marketplace
39 | # - name: Publish Plugin
40 | # env:
41 | # PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
42 | # run: ./gradlew publishPlugin
43 |
44 | # Upload artifact as a release asset
45 | - name: Upload Release Asset
46 | env:
47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 | run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
49 |
50 | # Create pull request
51 | - name: Create Pull Request
52 | env:
53 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 | run: |
55 | VERSION="${{ github.event.release.tag_name }}"
56 | BRANCH="changelog-update-$VERSION"
57 |
58 | git config user.email "action@github.com"
59 | git config user.name "GitHub Action"
60 |
61 | git checkout -b $BRANCH
62 | git commit -am "Changelog update - $VERSION"
63 | git push --set-upstream origin $BRANCH
64 |
65 | gh pr create \
66 | --title "Changelog update - \`$VERSION\`" \
67 | --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
68 | --base main \
69 | --head $BRANCH
70 |
--------------------------------------------------------------------------------
/.github/workflows/run-ui-tests.yml:
--------------------------------------------------------------------------------
1 | # GitHub Actions Workflow created for launching UI tests on Linux, Windows, and Mac in the following steps:
2 | # - prepare and launch Idea with your plugin and robot-server plugin, which is need to interact with UI
3 | # - wait for the Idea started
4 | # - run UI tests with separate Gradle task
5 | #
6 | # Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ IDEA.
7 | #
8 | # Workflow is triggered manually.
9 |
10 | name: Run UI Tests
11 | on:
12 | workflow_dispatch
13 |
14 | jobs:
15 |
16 | testUI:
17 | runs-on: ${{ matrix.os }}
18 | strategy:
19 | fail-fast: false
20 | matrix:
21 | include:
22 | - os: ubuntu-latest
23 | runIde: |
24 | export DISPLAY=:99.0
25 | Xvfb -ac :99 -screen 0 1920x1080x16 &
26 | gradle runIdeForUiTests &
27 | - os: windows-latest
28 | runIde: start gradlew.bat runIdeForUiTests
29 | - os: macos-latest
30 | runIde: ./gradlew runIdeForUiTests &
31 |
32 | steps:
33 |
34 | # Check out current repository
35 | - name: Fetch Sources
36 | uses: actions/checkout@v2.3.4
37 |
38 | # Setup Java 17 environment for the next steps
39 | - name: Setup Java
40 | uses: actions/setup-java@v2
41 | with:
42 | distribution: zulu
43 | java-version: 17
44 | cache: gradle
45 |
46 | # Run IDEA prepared for UI testing
47 | - name: Run IDE
48 | run: ${{ matrix.runIde }}
49 |
50 | # Wait for IDEA to be started
51 | - name: Health Check
52 | uses: jtalk/url-health-check-action@v1.5
53 | with:
54 | url: http://127.0.0.1:8082
55 | max-attempts: 15
56 | retry-delay: 30s
57 |
58 | # Run tests
59 | - name: Tests
60 | run: ./gradlew test
61 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .idea
3 | .intellijPlatform
4 | .qodana
5 | build
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/.run/Run IDE for UI Tests.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
15 |
16 |
17 | true
18 | true
19 | false
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.run/Run IDE with Plugin.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
17 |
18 |
19 | true
20 | true
21 | false
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.run/Run Plugin Tests.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | true
20 | true
21 | false
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.run/Run Plugin Verification.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | true
20 | true
21 | false
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # .NET Watch Run Configuration Changelog
4 |
5 | ## Unreleased
6 |
7 | ## 2024.1.1
8 | - Compatibility with Rider 2024.1
9 |
10 | ## 2024.1.0
11 | - Compatibility with Rider 2024.1 EAP
12 |
13 | ## 2023.3.5
14 | - Add watch arguments field #10
15 |
16 | ## 2023.3.4
17 | - Improved compatibility with Rider 2023.3
18 | - Make dotnet-watch run configuration available while indexing
19 | - Add error reporting through JetBrains Marketplace
20 |
21 | ## 2023.3.3
22 | - Program Argument --applicationpath keeps getting added [#9](https://github.com/maartenba/DotNetWatch/issues/9)
23 |
24 | ## 2023.3.2
25 | - Improved compatibility with Rider 2023.3
26 |
27 | ## 2023.3.1
28 | - Fix generating --framework flag when only one TFM is specified [#7](https://github.com/maartenba/DotNetWatch/issues/7)
29 |
30 | ## 2023.3.0
31 | - Compatibility with Rider 2023.3
32 |
33 | ## 2023.2.5
34 | - Program Argument --applicationpath keeps getting added [#9](https://github.com/maartenba/DotNetWatch/issues/9)
35 |
36 | ## 2023.2.4
37 | - Fix generating --framework flag when only one TFM is specified [#7](https://github.com/maartenba/DotNetWatch/issues/7)
38 |
39 | ## 2023.2.3
40 | - Update dependencies
41 |
42 | ## 2023.2.2
43 | - Update dependencies
44 |
45 | ## 2023.2.1
46 | - Automatically pick latest target framework on run if configured target framework is no longer available
47 |
48 | ## 2023.2.0
49 | - Compatibility with Rider 2023.2
50 |
51 | ## 2023.1.1
52 | - Minor compatibility fixes
53 |
54 | ## 2023.1.0
55 | - Compatibility with Rider 2023.1
56 |
57 | ## 2022.3.0
58 | - Add checkbox for DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH, DOTNET_USE_POLLING_FILE_WATCHER
59 | - Add checkbox to disable automatic browser launch [#5](https://github.com/maartenba/DotNetWatch/issues/5)
60 | - Do not stop dotnet watch process when a build is started [#4](https://github.com/maartenba/DotNetWatch/issues/4)
61 | - Compatibility with Rider 2022.3
62 |
63 | ## 2022.2.3
64 | - Fix issue where working directory was not updated when changing selected project
65 |
66 | ## 2022.2.2
67 | - Compatibility with Rider 2022.2
68 |
69 | ## 2022.2.1
70 | - Compatibility with Rider 2022.2 EAP9
71 |
72 | ## 2022.2.0
73 | - Compatibility with Rider 2022.2 EAP1
74 |
75 | ## 2022.1.0
76 | - Compatibility with Rider 2022.1
77 |
78 | ## 0.1.6
79 |
80 | ### Added
81 | - Add checkbox for DOTNET_WATCH_RESTART_ON_RUDE_EDIT [#3](https://github.com/maartenba/DotNetWatch/issues/3)
82 |
83 | ## 0.1.5
84 |
85 | ### Added
86 | - Compatibility with Rider 2022.1 EAP
87 |
88 | ## 0.1.4
89 |
90 | ### Fixes
91 | - Unable to use hotreload with --framework flag in command line [#2](https://github.com/maartenba/DotNetWatch/issues/2)
92 |
93 | ## 0.1.3
94 |
95 | ### Added
96 | - Compatibility with Rider 2021.3 RTM
97 |
98 | ## 0.1.2
99 |
100 | ### Fixes
101 | - Working directory not updating in projects with multiple targets
102 | - Duplicate projects in project selector are no longer shown
103 | - Loading configuration editor no longer shows blank fields
104 |
105 | ## 0.1.1
106 |
107 | ### Added
108 | - Add initial support for `dotnet-watch` run configurations
109 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 JetBrains Developer Advocates
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > **This plugin is bundled as part of Rider 2024.2 and newer.**
2 |
3 | # .NET Watch Run Configuration
4 |
5 |
6 | A .NET Watch Run Configuration (`dotnet-watch`) that can be used in Rider.
7 |
8 | `dotnet-watch` is a .NET global tool that can track file changes during development and restart the target command. This plug-in allows users to utilize the standard features of Rider's run configuration to add a `dotnet-watch` quickly to any runnable project. Runnable projects include console applications, ASP.NET Core web apps, and Desktop applications. This plug-in also exposes some of the latest flags from the .NET 6 implementation of `dotnet-watch`, meaning not all flags are applicable if you use an SDK version before .NET 6.
9 |
10 | Features include:
11 |
12 | - Project Selection
13 | - Target Framework Selection
14 | - Program Arguments
15 | - Working Directory
16 | - Environment Variables editor
17 | - Use External Console flag
18 | - Verbosity (`--quiet`, `--verbose`, or default)
19 | - Suppress Hot Reload (only .NET 6+)
20 | - Before Launch options
21 |
22 |
23 |
24 | Plugin built by the JetBrains Developer Advocates.
25 |
26 | ## Screenshots
27 |
28 | ### Plugins Screen
29 |
30 | 
31 |
32 | ### Settings
33 |
34 | 
35 |
36 | ### Running In JetBrains Rider
37 |
38 | 
39 |
40 | ## Installation
41 |
42 | - Using IDE built-in plugin system:
43 |
44 | Settings/Preferences > Plugins > Marketplace > Search for ".NET Watch Run Configuration" >
45 | Install Plugin
46 |
47 | - Manually:
48 |
49 | Download the [latest release](https://github.com/maartenba/DotNetWatch/releases/latest) and install it manually using
50 | Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...
51 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.changelog.markdownToHTML
2 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3 |
4 | fun properties(key: String) = project.findProperty(key).toString()
5 |
6 | plugins {
7 | // Java support
8 | id("java")
9 | // Kotlin support
10 | id("org.jetbrains.kotlin.jvm") version "1.8.21"
11 | // Gradle IntelliJ Plugin
12 | id("org.jetbrains.intellij.platform") version "2.0.0-beta3"
13 | // Gradle Changelog Plugin
14 | id("org.jetbrains.changelog") version "2.0.0"
15 | }
16 |
17 | group = properties("pluginGroup")
18 | version = properties("pluginVersion")
19 | val platformType = properties("platformType")
20 | val platformVersion = properties("platformVersion")
21 |
22 | // Configure project's dependencies
23 | repositories {
24 | mavenCentral()
25 | intellijPlatform {
26 | defaultRepositories()
27 | }
28 | }
29 |
30 | dependencies {
31 | intellijPlatform {
32 | create(platformType, platformVersion)
33 |
34 | pluginVerifier()
35 | zipSigner()
36 | instrumentationTools()
37 | }
38 | }
39 |
40 | // Set the JVM language level used to compile sources and generate files
41 | kotlin {
42 | jvmToolchain {
43 | languageVersion.set(JavaLanguageVersion.of(17))
44 | }
45 | }
46 |
47 | // Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
48 | intellijPlatform {
49 | pluginConfiguration {
50 | name = properties("pluginName")
51 | version = properties("pluginVersion")
52 |
53 | ideaVersion {
54 | // TODO migration is this needed?
55 | // sinceBuild.set(properties("pluginSinceBuild"))
56 | // untilBuild.set(properties("pluginUntilBuild"))
57 | }
58 |
59 | // Extract the section from README.md and provide for the plugin's manifest
60 | description.set(
61 | projectDir.resolve("README.md").readText().lines().run {
62 | val start = ""
63 | val end = ""
64 |
65 | if (!containsAll(listOf(start, end))) {
66 | throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
67 | }
68 | subList(indexOf(start) + 1, indexOf(end))
69 | }.joinToString("\n").run { markdownToHTML(this) }
70 | )
71 |
72 | // Get the latest available change notes from the changelog file
73 | changeNotes.set(provider {
74 | changelog.run {
75 | getOrNull(properties("pluginVersion")) ?: getLatest()
76 | }.toHTML()
77 | })
78 | }
79 |
80 | // Plugin verifier
81 | verifyPlugin {
82 | ides {
83 | recommended()
84 | }
85 | }
86 | }
87 |
88 | // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
89 | changelog {
90 | version.set(properties("pluginVersion"))
91 | groups.set(emptyList())
92 | }
93 |
94 | tasks {
95 | // Set the JVM compatibility versions
96 | properties("javaVersion").let {
97 | withType {
98 | sourceCompatibility = it
99 | targetCompatibility = it
100 | }
101 | withType {
102 | kotlinOptions.jvmTarget = it
103 | }
104 | }
105 |
106 | wrapper {
107 | gradleVersion = properties("gradleVersion")
108 | }
109 |
110 | signPlugin {
111 | certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
112 | privateKey.set(System.getenv("PRIVATE_KEY"))
113 | password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
114 | }
115 |
116 | publishPlugin {
117 | dependsOn("patchChangelog")
118 | token.set(System.getenv("PUBLISH_TOKEN"))
119 | // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
120 | // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
121 | // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
122 | channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
123 | }
124 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # IntelliJ Platform Artifacts Repositories
2 | # -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
3 |
4 | pluginGroup = org.jetbrains.advocates.rider.plugins.dotnetwatch
5 | pluginName = DotNetWatch
6 | pluginVersion = 2024.2.0
7 |
8 | # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
9 | # for insight into build numbers and IntelliJ Platform versions.
10 | pluginSinceBuild = 241
11 | pluginUntilBuild = 241.*
12 |
13 | platformType = RD
14 | #platformVersion = 2024.1-EAP1-SNAPSHOT
15 | platformVersion = 2024.1
16 |
17 | # Java language level used to compile sources and to generate the files for
18 | javaVersion = 17
19 |
20 | gradleVersion = 8.2
21 |
22 | # Opt-out flag for bundling Kotlin standard library.
23 | # See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
24 | # suppress inspection "UnusedProperty"
25 | kotlin.stdlib.default.dependency = false
26 |
27 | # https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin-faq.html#kotlin-compiler-throws-out-of-memory-java-heap-space-error
28 | kotlin.incremental.useClasspathSnapshot=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maartenba/DotNetWatch/693c326753a6141bae07dbaf7fe5016727fa1240/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4 | networkTimeout=10000
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147 | # shellcheck disable=SC3045
148 | MAX_FD=$( ulimit -H -n ) ||
149 | warn "Could not query maximum file descriptor limit"
150 | esac
151 | case $MAX_FD in #(
152 | '' | soft) :;; #(
153 | *)
154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155 | # shellcheck disable=SC3045
156 | ulimit -n "$MAX_FD" ||
157 | warn "Could not set maximum file descriptor limit to $MAX_FD"
158 | esac
159 | fi
160 |
161 | # Collect all arguments for the java command, stacking in reverse order:
162 | # * args from the command line
163 | # * the main class name
164 | # * -classpath
165 | # * -D...appname settings
166 | # * --module-path (only if needed)
167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168 |
169 | # For Cygwin or MSYS, switch paths to Windows format before running java
170 | if "$cygwin" || "$msys" ; then
171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173 |
174 | JAVACMD=$( cygpath --unix "$JAVACMD" )
175 |
176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
177 | for arg do
178 | if
179 | case $arg in #(
180 | -*) false ;; # don't mess with options #(
181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182 | [ -e "$t" ] ;; #(
183 | *) false ;;
184 | esac
185 | then
186 | arg=$( cygpath --path --ignore --mixed "$arg" )
187 | fi
188 | # Roll the args list around exactly as many times as the number of
189 | # args, so each arg winds up back in the position where it started, but
190 | # possibly modified.
191 | #
192 | # NB: a `for` loop captures its iteration list before it begins, so
193 | # changing the positional parameters here affects neither the number of
194 | # iterations, nor the values presented in `arg`.
195 | shift # remove old arg
196 | set -- "$@" "$arg" # push replacement arg
197 | done
198 | fi
199 |
200 | # Collect all arguments for the java command;
201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202 | # shell script including quotes and variable substitutions, so put them in
203 | # double quotes to make sure that they get re-expanded; and
204 | # * put everything else in single quotes, so that it's not re-expanded.
205 |
206 | set -- \
207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
208 | -classpath "$CLASSPATH" \
209 | org.gradle.wrapper.GradleWrapperMain \
210 | "$@"
211 |
212 | # Stop when "xargs" is not available.
213 | if ! command -v xargs >/dev/null 2>&1
214 | then
215 | die "xargs is not available"
216 | fi
217 |
218 | # Use "xargs" to parse quoted args.
219 | #
220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
221 | #
222 | # In Bash we could simply go:
223 | #
224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
225 | # set -- "${ARGS[@]}" "$@"
226 | #
227 | # but POSIX shell has neither arrays nor command substitution, so instead we
228 | # post-process each arg (as a line of input to sed) to backslash-escape any
229 | # character that might be a shell metacharacter, then use eval to reverse
230 | # that process (while maintaining the separation between arguments), and wrap
231 | # the whole thing up as a single "set" statement.
232 | #
233 | # This will of course break if any of these variables contains a newline or
234 | # an unmatched quote.
235 | #
236 |
237 | eval "set -- $(
238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
239 | xargs -n1 |
240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
241 | tr '\n' ' '
242 | )" '"$@"'
243 |
244 | exec "$JAVACMD" "$@"
245 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/images/plugins-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maartenba/DotNetWatch/693c326753a6141bae07dbaf7fe5016727fa1240/images/plugins-screen.png
--------------------------------------------------------------------------------
/images/run-configuration-running.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maartenba/DotNetWatch/693c326753a6141bae07dbaf7fe5016727fa1240/images/run-configuration-running.png
--------------------------------------------------------------------------------
/images/run-configuration-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maartenba/DotNetWatch/693c326753a6141bae07dbaf7fe5016727fa1240/images/run-configuration-settings.png
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "DotNetWatch"
2 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/DotNetWatchBundle.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch
2 |
3 | import com.intellij.DynamicBundle
4 | import org.jetbrains.annotations.NonNls
5 | import org.jetbrains.annotations.PropertyKey
6 |
7 | @NonNls
8 | private const val BUNDLE = "messages.DotNetWatchBundle"
9 |
10 | object DotNetWatchBundle : DynamicBundle(BUNDLE) {
11 |
12 | @Suppress("SpreadOperator")
13 | @JvmStatic
14 | fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
15 | getMessage(key, *params)
16 |
17 | @Suppress("SpreadOperator", "unused")
18 | @JvmStatic
19 | fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
20 | getLazyMessage(key, *params)
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/DotNetWatchIcons.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("PackageDirectoryMismatch")
2 |
3 | package icons
4 |
5 | import com.intellij.openapi.util.IconLoader
6 | import javax.swing.Icon
7 |
8 | @Suppress("SameParameterValue")
9 | object DotNetWatchIcons {
10 | @JvmField val RunConfiguration = load("runConfiguration.svg")
11 |
12 | private fun load(path: String): Icon = IconLoader.getIcon("/icons/$path", this::class.java)
13 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfiguration.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.execution.DefaultExecutionResult
4 | import com.intellij.execution.ExecutionException
5 | import com.intellij.execution.ExecutionResult
6 | import com.intellij.execution.Executor
7 | import com.intellij.execution.configurations.*
8 | import com.intellij.execution.process.ProcessHandler
9 | import com.intellij.execution.process.ProcessTerminatedListener
10 | import com.intellij.execution.runners.ExecutionEnvironment
11 | import com.intellij.execution.runners.ProgramRunner
12 | import com.intellij.openapi.actionSystem.AnAction
13 | import com.intellij.openapi.options.SettingsEditor
14 | import com.intellij.openapi.project.DumbAware
15 | import com.intellij.openapi.project.Project
16 | import com.intellij.util.execution.ParametersListUtil
17 | import com.jetbrains.rider.debugger.showElevationDialogIfNeeded
18 | import com.jetbrains.rider.projectView.solutionDirectory
19 | import com.jetbrains.rider.run.*
20 | import com.jetbrains.rider.run.configurations.BuildAwareRunConfiguration
21 | import com.jetbrains.rider.run.configurations.project.DotNetProjectConfigurationType
22 | import com.jetbrains.rider.run.configurations.runnableProjectsModelIfAvailable
23 | import com.jetbrains.rider.runtime.RiderDotNetActiveRuntimeHost
24 | import com.jetbrains.rider.util.idea.getService
25 | import java.io.File
26 |
27 | class DotNetWatchRunConfiguration(project: Project, factory: ConfigurationFactory, name: String)
28 | : RunConfigurationBase(project, factory, name), BuildAwareRunConfiguration, DumbAware {
29 |
30 | private val riderDotNetActiveRuntimeHost = project.getService()
31 |
32 | fun watchOptions() = options
33 |
34 | // For filtering list of projects - show only console/web/wcf/dotnetcore, not launchsettings etc.
35 | private val type = DotNetProjectConfigurationType()
36 |
37 | override fun getOptions(): DotNetWatchRunConfigurationOptions =
38 | super.getOptions() as DotNetWatchRunConfigurationOptions
39 |
40 | override fun getConfigurationEditor(): SettingsEditor = DotNetWatchRunConfigurationEditor(project)
41 |
42 | override fun getState(executor: Executor, executionEnvironment: ExecutionEnvironment): RunProfileState {
43 | return object : CommandLineState(executionEnvironment) {
44 |
45 | override fun execute(executor: Executor, runner: ProgramRunner<*>): ExecutionResult {
46 | try {
47 | val dotNetExePath = riderDotNetActiveRuntimeHost.dotNetCoreRuntime.value
48 | ?: throw ExecutionException("Could not determine active .NET runtime.")
49 |
50 | // Create command line
51 | val commandLine = createEmptyConsoleCommandLine(options.useExternalConsole)
52 | commandLine.exePath = dotNetExePath.cliExePath
53 | commandLine.addParameters(
54 | listOf(
55 | "watch",
56 | "run",
57 | "--project", options.projectFilePath
58 | )
59 | )
60 |
61 | // Determine target framework version parameter
62 | project.runnableProjectsModelIfAvailable?.projects?.valueOrNull?.let { runnableProjects ->
63 | val runnableProject = runnableProjects.singleOrNull {
64 | it.projectFilePath == options.projectFilePath && type.isApplicable(it.kind)
65 | } ?: return@let
66 |
67 | // Use configured/available TFM
68 | if (runnableProject.projectOutputs.size > 1 && runnableProject.projectOutputs.any { it.tfm?.presentableName == options.projectTfm }) {
69 | commandLine.addParameters("--framework", options.projectTfm)
70 | }
71 | }
72 |
73 | options.verbosity.argumentValue?.let { commandLine.addParameter(it) }
74 |
75 | if (options.isSuppressHotReload) {
76 | commandLine.addParameter("--no-hot-reload")
77 | }
78 |
79 | if (options.watchParameters.isNotEmpty()) {
80 | commandLine.parametersList.addAll(
81 | ParametersListUtil.parse(options.watchParameters))
82 | }
83 |
84 | if (options.programParameters.isNotEmpty()) {
85 | commandLine.addParameter("--")
86 | commandLine.parametersList.addAll(
87 | ParametersListUtil.parse(options.programParameters))
88 | }
89 |
90 | val workingDirectory = File(options.workingDirectory)
91 | commandLine.workDirectory = if (workingDirectory.exists()) workingDirectory else project.solutionDirectory
92 | commandLine.withParentEnvironmentType(if (options.isPassParentEnvs) GeneralCommandLine.ParentEnvironmentType.CONSOLE else GeneralCommandLine.ParentEnvironmentType.NONE)
93 | commandLine.withEnvironment(options.envs)
94 |
95 | if (options.isRestartOnRudeEditEditor) {
96 | commandLine.withEnvironment("DOTNET_WATCH_RESTART_ON_RUDE_EDIT", "true")
97 | }
98 | if (options.isUsePollingFileWatcher) {
99 | commandLine.withEnvironment("DOTNET_USE_POLLING_FILE_WATCHER", "true")
100 | }
101 | if (options.isSuppressBrowserLaunch) {
102 | commandLine.withEnvironment("DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER", "true")
103 | }
104 | if (options.isSuppressBrowserRefresh) {
105 | commandLine.withEnvironment("DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH", "true")
106 | }
107 |
108 | // Start process
109 | val processHandler = if (options.useExternalConsole)
110 | ExternalConsoleMediator.createProcessHandler(commandLine)
111 | else
112 | TerminalProcessHandler(project, commandLine)
113 |
114 | ProcessTerminatedListener.attach(processHandler)
115 |
116 | // Create console
117 | val console = createConsole(
118 | consoleKind = if (options.useExternalConsole) ConsoleKind.ExternalConsole else ConsoleKind.Normal,
119 | processHandler = processHandler,
120 | project = project
121 | )
122 |
123 | return DefaultExecutionResult(console, processHandler, *AnAction.EMPTY_ARRAY)
124 | } catch (t: Throwable) {
125 | showElevationDialogIfNeeded(t, environment.project)
126 | throw ExecutionException(t)
127 | }
128 | }
129 |
130 | override fun startProcess(): ProcessHandler {
131 | @Suppress("DialogTitleCapitalization")
132 | throw ExecutionException("startProcess() should not be called.")
133 | }
134 | }
135 | }
136 |
137 | override fun mustBeStoppedToRunBuild(): Boolean = false
138 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationEditor.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.util.io.FileUtil
6 | import com.jetbrains.rd.util.lifetime.Lifetime
7 | import com.jetbrains.rdclient.protocol.IPermittedModalities
8 | import com.jetbrains.rider.model.runnableProjectsModel
9 | import com.jetbrains.rider.projectView.solution
10 | import com.jetbrains.rider.run.RiderRunBundle
11 | import com.jetbrains.rider.run.configurations.ProtocolLifetimedSettingsEditor
12 | import com.jetbrains.rider.run.configurations.controls.*
13 | import com.jetbrains.rider.run.configurations.runnableProjectsModelIfAvailable
14 | import org.jetbrains.advocates.rider.plugins.dotnetwatch.DotNetWatchBundle
15 | import java.util.*
16 | import javax.swing.JComponent
17 |
18 | class DotNetWatchRunConfigurationEditor(private val project: Project)
19 | : ProtocolLifetimedSettingsEditor() {
20 |
21 | private lateinit var viewModel: DotNetWatchRunConfigurationViewModel
22 |
23 | override fun createEditor(lifetime: Lifetime) : JComponent {
24 | IPermittedModalities.getInstance().allowPumpProtocolUnderCurrentModality()
25 |
26 | viewModel = DotNetWatchRunConfigurationViewModel(
27 | lifetime,
28 | project,
29 | project.solution.runnableProjectsModel,
30 | ProjectSelector(DotNetWatchBundle.message("run.configuration.project.label"), "Project"),
31 | StringSelector(DotNetWatchBundle.message("run.configuration.tfm.label"), "Target_framework"),
32 | ProgramParametersEditor(DotNetWatchBundle.message("run.configuration.programParameters.label"), "Program_arguments", lifetime),
33 | PathSelector(DotNetWatchBundle.message("run.configuration.workingDirectory.label"), "Working_directory", FileChooserDescriptorFactory.createSingleFolderDescriptor(), lifetime),
34 | EnvironmentVariablesEditor(DotNetWatchBundle.message("run.configuration.environmentVariables.label"), "Environment_variables"),
35 | FlagEditor(DotNetWatchBundle.message("run.configuration.useExternalConsole.label"), "Use_external_console"),
36 | ViewSeparator(DotNetWatchBundle.message("run.configuration.separator.additional.label")),
37 | ProgramParametersEditor(DotNetWatchBundle.message("run.configuration.watchParameters.label"), "Watch_arguments", lifetime),
38 | EnumSelector(DotNetWatchBundle.message("run.configuration.verbosity.label"), "Dotnet_watch_verbosity", EnumSet.allOf(DotNetWatchVerbosity::class.java)) {
39 | when (it) {
40 | DotNetWatchVerbosity.NORMAL -> DotNetWatchBundle.message("run.configuration.verbosity.normal")
41 | DotNetWatchVerbosity.QUIET -> DotNetWatchBundle.message("run.configuration.verbosity.quiet")
42 | DotNetWatchVerbosity.VERBOSE -> DotNetWatchBundle.message("run.configuration.verbosity.verbose")
43 | }
44 | },
45 | FlagEditor(DotNetWatchBundle.message("run.configuration.isSuppressHotReload.label"), "Dotnet_watch_suppress_hotreload"),
46 | FlagEditor(DotNetWatchBundle.message("run.configuration.isRestartOnRudeEdit.label"), "Dotnet_watch_restart_on_rude_edit"),
47 | FlagEditor(DotNetWatchBundle.message("run.configuration.isUsePollingFileWatcher.label"), "Dotnet_watch_use_polling"),
48 | ViewSeparator(DotNetWatchBundle.message("run.configuration.separator.browser.label")),
49 | FlagEditor(DotNetWatchBundle.message("run.configuration.isSuppressBrowserLaunch.label"), "Dotnet_watch_suppress_browser_launch"),
50 | FlagEditor(DotNetWatchBundle.message("run.configuration.isSuppressBrowserRefresh.label"), "Dotnet_watch_suppress_browser_refresh")
51 | )
52 |
53 | return ControlViewBuilder(lifetime, project).build(viewModel)
54 | }
55 |
56 | override fun resetEditorFrom(runConfiguration: DotNetWatchRunConfiguration) {
57 | runConfiguration.watchOptions().apply {
58 | viewModel.reset(
59 | projectFilePath,
60 | trackProjectExePath,
61 | trackProjectWorkingDirectory,
62 | projectTfm,
63 | exePath,
64 | programParameters,
65 | workingDirectory,
66 | envs,
67 | isPassParentEnvs,
68 | useExternalConsole,
69 | isUnloadedProject(project),
70 | watchParameters,
71 | verbosity,
72 | isSuppressHotReload,
73 | isRestartOnRudeEditEditor,
74 | isUsePollingFileWatcher,
75 | isSuppressBrowserLaunch,
76 | isSuppressBrowserRefresh
77 | )
78 | }
79 | }
80 |
81 | override fun applyEditorTo(runConfiguration: DotNetWatchRunConfiguration) {
82 | // Hold off when still loading solution...
83 | if (project.runnableProjectsModelIfAvailable?.projects?.valueOrNull == null) {
84 | RiderRunBundle.message("solution.is.loading.please.wait")
85 | }
86 |
87 | val selectedProject = viewModel.projectSelector.project.valueOrNull
88 | val selectedTfm = viewModel.tfmSelector.string.valueOrNull
89 | if (selectedProject != null && selectedTfm != null) {
90 | runConfiguration.watchOptions().apply {
91 | projectFilePath = selectedProject.projectFilePath
92 | trackProjectExePath = viewModel.trackProjectExePath
93 | trackProjectWorkingDirectory = viewModel.trackProjectWorkingDirectory
94 | projectTfm = selectedTfm
95 | exePath = FileUtil.toSystemIndependentName(viewModel.exePathSelector.path.value)
96 | programParameters = viewModel.programParametersEditor.parametersString.value
97 | workingDirectory = FileUtil.toSystemIndependentName(viewModel.workingDirectorySelector.path.value)
98 | envs = viewModel.environmentVariablesEditor.envs.value
99 | isPassParentEnvs = viewModel.environmentVariablesEditor.isPassParentEnvs.value
100 | useExternalConsole = viewModel.useExternalConsoleEditor.isSelected.value
101 | watchParameters = viewModel.watchParametersEditor.parametersString.value
102 | verbosity = viewModel.verbosityEditor.rawValue.valueOrNull ?: DotNetWatchVerbosity.NORMAL
103 | isSuppressHotReload = viewModel.isSuppressHotReloadEditor.isSelected.value
104 | isRestartOnRudeEditEditor = viewModel.isRestartOnRudeEditEditor.isSelected.value
105 | isUsePollingFileWatcher = viewModel.isUsePollingFileWatcherEditor.isSelected.value
106 | isSuppressBrowserLaunch = viewModel.isSuppressBrowserLaunchEditor.isSelected.value
107 | isSuppressBrowserRefresh = viewModel.isSuppressBrowserRefreshEditor.isSelected.value
108 | }
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationFactory.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.execution.configurations.ConfigurationFactory
4 | import com.intellij.openapi.components.BaseState
5 | import com.intellij.openapi.project.Project
6 |
7 | class DotNetWatchRunConfigurationFactory(configurationType: DotNetWatchRunConfigurationType)
8 | : ConfigurationFactory(configurationType) {
9 |
10 | override fun getId() = DotNetWatchRunConfigurationType.ID
11 |
12 | override fun createTemplateConfiguration(project: Project) =
13 | DotNetWatchRunConfiguration(project, this, "Run dotnet-watch")
14 |
15 | override fun getOptionsClass(): Class = DotNetWatchRunConfigurationOptions::class.java
16 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationOptions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("UnstableApiUsage")
2 |
3 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
4 |
5 | import com.intellij.execution.configurations.RunConfigurationOptions
6 | import com.intellij.openapi.project.Project
7 | import com.intellij.platform.backend.workspace.WorkspaceModel
8 | import com.jetbrains.rider.projectView.workspace.getProjectModelEntities
9 | import com.jetbrains.rider.projectView.workspace.isUnloadedProject
10 | import java.nio.file.Path
11 |
12 | class DotNetWatchRunConfigurationOptions : RunConfigurationOptions() {
13 |
14 | private var projectFilePathOption = string("").provideDelegate(this, "projectFilePath")
15 | private var trackProjectExePathOption = property(true).provideDelegate(this, "trackProjectExePath")
16 | private var trackProjectWorkingDirectoryOption = property(true).provideDelegate(this, "trackProjectWorkingDirectory")
17 | private var projectTfmOption = string("").provideDelegate(this, "projectTfm")
18 | private var exePathOption = string("").provideDelegate(this, "exePath")
19 | private var programParametersOption = string("").provideDelegate(this, "programParameters")
20 | private var workingDirectoryOption = string("").provideDelegate(this, "workingDirectory")
21 | private var envsOption = map().provideDelegate(this, "envs")
22 | private var isPassParentEnvsOption = property(true).provideDelegate(this, "isPassParentEnvs")
23 | private var useExternalConsoleOption = property(false).provideDelegate(this, "useExternalConsole")
24 | private var watchParametersOption = string("").provideDelegate(this, "watchParameters")
25 | private var verbosityOption = string(DotNetWatchVerbosity.NORMAL.name).provideDelegate(this, "verbosity")
26 | private var isSuppressHotReloadOption = property(false).provideDelegate(this, "isSuppressHotReload")
27 | private var isRestartOnRudeEditEditorOption = property(false).provideDelegate(this, "isRestartOnRudeEditEditor")
28 | private var isUsePollingFileWatcherOption = property(false).provideDelegate(this, "isUsePollingFileWatcher")
29 | private var isSuppressBrowserLaunchOption = property(false).provideDelegate(this, "isSuppressBrowserLaunch")
30 | private var isSuppressBrowserRefreshOption = property(false).provideDelegate(this, "isSuppressBrowserRefresh")
31 |
32 | var projectFilePath: String
33 | get() = projectFilePathOption.getValue(this) ?: ""
34 | set(value) = projectFilePathOption.setValue(this, value)
35 |
36 | var trackProjectExePath: Boolean
37 | get() = trackProjectExePathOption.getValue(this)
38 | set(value) = trackProjectExePathOption.setValue(this, value)
39 |
40 | var trackProjectWorkingDirectory: Boolean
41 | get() = trackProjectWorkingDirectoryOption.getValue(this)
42 | set(value) = trackProjectWorkingDirectoryOption.setValue(this, value)
43 |
44 | var projectTfm: String
45 | get() = projectTfmOption.getValue(this) ?: ""
46 | set(value) = projectTfmOption.setValue(this, value)
47 |
48 | var exePath: String
49 | get() = exePathOption.getValue(this) ?: ""
50 | set(value) = exePathOption.setValue(this, value)
51 |
52 | var programParameters: String
53 | get() = programParametersOption.getValue(this) ?: ""
54 | set(value) = programParametersOption.setValue(this, value)
55 |
56 | var workingDirectory: String
57 | get() = workingDirectoryOption.getValue(this) ?: ""
58 | set(value) = workingDirectoryOption.setValue(this, value)
59 |
60 | var envs: Map
61 | get() = envsOption.getValue(this)
62 | set(value) = envsOption.setValue(this, value.toMutableMap())
63 |
64 | var isPassParentEnvs: Boolean
65 | get() = isPassParentEnvsOption.getValue(this)
66 | set(value) = isPassParentEnvsOption.setValue(this, value)
67 |
68 | var useExternalConsole: Boolean
69 | get() = useExternalConsoleOption.getValue(this)
70 | set(value) = useExternalConsoleOption.setValue(this, value)
71 |
72 | var watchParameters: String
73 | get() = watchParametersOption.getValue(this) ?: ""
74 | set(value) = watchParametersOption.setValue(this, value)
75 |
76 | var verbosity: DotNetWatchVerbosity
77 | get() = DotNetWatchVerbosity.valueOf(verbosityOption.getValue(this) ?: DotNetWatchVerbosity.NORMAL.name)
78 | set(value) = verbosityOption.setValue(this, value.name)
79 |
80 | var isSuppressHotReload: Boolean
81 | get() = isSuppressHotReloadOption.getValue(this)
82 | set(value) = isSuppressHotReloadOption.setValue(this, value)
83 |
84 | var isRestartOnRudeEditEditor: Boolean
85 | get() = isRestartOnRudeEditEditorOption.getValue(this)
86 | set(value) = isRestartOnRudeEditEditorOption.setValue(this, value)
87 |
88 | var isUsePollingFileWatcher: Boolean
89 | get() = isUsePollingFileWatcherOption.getValue(this)
90 | set(value) = isUsePollingFileWatcherOption.setValue(this, value)
91 |
92 | var isSuppressBrowserLaunch: Boolean
93 | get() = isSuppressBrowserLaunchOption.getValue(this)
94 | set(value) = isSuppressBrowserLaunchOption.setValue(this, value)
95 |
96 | var isSuppressBrowserRefresh: Boolean
97 | get() = isSuppressBrowserRefreshOption.getValue(this)
98 | set(value) = isSuppressBrowserRefreshOption.setValue(this, value)
99 |
100 | fun isUnloadedProject(project: Project) = WorkspaceModel.getInstance(project)
101 | .getProjectModelEntities(Path.of(projectFilePath), project)
102 | .any { it.isUnloadedProject() }
103 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationProducer.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.execution.actions.ConfigurationContext
4 | import com.intellij.execution.actions.LazyRunConfigurationProducer
5 | import com.intellij.execution.configurations.ConfigurationTypeUtil
6 | import com.intellij.openapi.util.Ref
7 | import com.intellij.openapi.util.io.FileUtil
8 | import com.intellij.openapi.util.io.systemIndependentPath
9 | import com.intellij.psi.PsiElement
10 | import com.jetbrains.rider.model.runnableProjectsModel
11 | import com.jetbrains.rider.projectView.solution
12 | import com.jetbrains.rider.projectView.workspace.getFile
13 | import com.jetbrains.rider.run.configurations.getSelectedProject
14 |
15 | // REVIEW this one overrides the default context menu | Run ..., which is not ideal - disabled for now
16 | class DotNetWatchRunConfigurationProducer
17 | : LazyRunConfigurationProducer() {
18 |
19 | override fun getConfigurationFactory() = ConfigurationTypeUtil.findConfigurationType(DotNetWatchRunConfigurationType::class.java)
20 | .configurationFactories
21 | .single()
22 |
23 | override fun isConfigurationFromContext(
24 | configuration: DotNetWatchRunConfiguration,
25 | context: ConfigurationContext
26 | ) : Boolean {
27 | val selectedProjectFilePathInvariant = context.getSelectedProject()?.getFile()?.systemIndependentPath ?: return false
28 |
29 | val projects = context.project.solution.runnableProjectsModel.projects.valueOrNull ?: return false
30 | val runnableProject = projects.firstOrNull {
31 | FileUtil.toSystemIndependentName(it.projectFilePath) == selectedProjectFilePathInvariant &&
32 | FileUtil.toSystemIndependentName(configuration.watchOptions().projectFilePath) == selectedProjectFilePathInvariant
33 | }
34 |
35 | return runnableProject != null
36 | }
37 |
38 | override fun setupConfigurationFromContext(
39 | configuration: DotNetWatchRunConfiguration,
40 | context: ConfigurationContext,
41 | psiElement: Ref
42 | ): Boolean {
43 | val selectedProjectFilePathInvariant = context.getSelectedProject()?.getFile()?.systemIndependentPath ?: return false
44 |
45 | val projects = context.project.solution.runnableProjectsModel.projects.valueOrNull ?: return false
46 | val runnableProject = projects.firstOrNull {
47 | FileUtil.toSystemIndependentName(it.projectFilePath) == selectedProjectFilePathInvariant
48 | } ?: return false
49 |
50 | if (configuration.name.isEmpty()) {
51 | configuration.name = runnableProject.name
52 | }
53 | configuration.watchOptions().projectFilePath = runnableProject.projectFilePath
54 |
55 | return true
56 | }
57 |
58 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationType.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.execution.configurations.ConfigurationType
4 | import com.intellij.openapi.project.PossiblyDumbAware
5 | import icons.DotNetWatchIcons
6 |
7 | @Suppress("DialogTitleCapitalization")
8 | class DotNetWatchRunConfigurationType : ConfigurationType, PossiblyDumbAware {
9 |
10 | companion object {
11 | // Do not change this once set
12 | const val ID = "RunDotNetWatch"
13 | }
14 |
15 | override fun getId() = ID
16 |
17 | override fun getIcon() = DotNetWatchIcons.RunConfiguration
18 |
19 | override fun getDisplayName() = "dotnet-watch"
20 |
21 | override fun getConfigurationTypeDescription() = "Runs dotnet watch"
22 |
23 | override fun getConfigurationFactories() = arrayOf(DotNetWatchRunConfigurationFactory(this))
24 |
25 | override fun isDumbAware() = true
26 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchRunConfigurationViewModel.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.util.execution.ParametersListUtil
5 | import com.jetbrains.rd.ide.model.EnvironmentVariable
6 | import com.jetbrains.rd.util.lifetime.Lifetime
7 | import com.jetbrains.rd.util.reactive.adviseOnce
8 | import com.jetbrains.rider.model.*
9 | import com.jetbrains.rider.run.configurations.RunnableProjectKinds
10 | import com.jetbrains.rider.run.configurations.controls.*
11 | import com.jetbrains.rider.run.configurations.controls.runtimeSelection.RuntimeSelector
12 | import com.jetbrains.rider.run.configurations.dotNetExe.DotNetExeConfigurationViewModel
13 | import com.jetbrains.rider.run.configurations.project.DotNetProjectConfigurationType
14 | import java.io.File
15 |
16 | class DotNetWatchRunConfigurationViewModel(
17 | private val lifetime: Lifetime,
18 | project: Project,
19 | private val runnableProjectsModel: RunnableProjectsModel,
20 | val projectSelector: ProjectSelector,
21 | val tfmSelector: StringSelector,
22 | programParametersEditor: ProgramParametersEditor,
23 | workingDirectorySelector: PathSelector,
24 | environmentVariablesEditor: EnvironmentVariablesEditor,
25 | useExternalConsoleEditor: FlagEditor,
26 | dotnetWatchAdditionalOptionsSeparator: ViewSeparator,
27 | val watchParametersEditor: ProgramParametersEditor,
28 | val verbosityEditor: EnumSelector,
29 | val isSuppressHotReloadEditor: FlagEditor,
30 | val isRestartOnRudeEditEditor: FlagEditor,
31 | val isUsePollingFileWatcherEditor: FlagEditor,
32 | dotnetWatchBrowserOptionsSeparator: ViewSeparator,
33 | val isSuppressBrowserLaunchEditor: FlagEditor,
34 | val isSuppressBrowserRefreshEditor: FlagEditor,
35 | ) : DotNetExeConfigurationViewModel(
36 | lifetime = lifetime,
37 | project = project,
38 | exePathSelector = PathSelector("", "Exe_path", null, lifetime),
39 | programParametersEditor = programParametersEditor,
40 | workingDirectorySelector = workingDirectorySelector,
41 | environmentVariablesEditor = environmentVariablesEditor,
42 | runtimeSelector = RuntimeSelector("", "Runtime", project, lifetime),
43 | runtimeArgumentsEditor = ProgramParametersEditor("", "Runtime_arguments", lifetime),
44 | trackExePathInWorkingDirectoryIfItPossible = false,
45 | useExternalConsoleEditor = useExternalConsoleEditor) {
46 |
47 | private var isLoaded = false
48 |
49 | // For filtering list of projects - show only console/web/wcf/dotnetcore, not launchsettings etc.
50 | private val type = DotNetProjectConfigurationType()
51 |
52 | var trackProjectExePath: Boolean = true
53 | var trackProjectWorkingDirectory: Boolean = true
54 |
55 | override val controls: List = listOf(
56 | projectSelector,
57 | tfmSelector,
58 | programParametersEditor,
59 | workingDirectorySelector,
60 | environmentVariablesEditor,
61 | useExternalConsoleEditor,
62 | dotnetWatchBrowserOptionsSeparator,
63 | isSuppressBrowserLaunchEditor,
64 | isSuppressBrowserRefreshEditor,
65 | dotnetWatchAdditionalOptionsSeparator,
66 | watchParametersEditor,
67 | verbosityEditor,
68 | isSuppressHotReloadEditor,
69 | isRestartOnRudeEditEditor,
70 | isUsePollingFileWatcherEditor
71 | )
72 |
73 | init {
74 | disable()
75 |
76 | projectSelector.bindTo(
77 | runnableProjectsModel = runnableProjectsModel,
78 | lifetime = lifetime,
79 | projectFilter = { p -> type.isApplicable(p.kind) },
80 | onLoad = ::enable,
81 | onSelect = ::handleProjectSelection
82 | )
83 |
84 | tfmSelector.string.advise(lifetime) { handleChangeTfmSelection() }
85 | exePathSelector.path.advise(lifetime) { recalculateTrackProjectOutput() }
86 | workingDirectorySelector.path.advise(lifetime) { recalculateTrackProjectOutput() }
87 | }
88 |
89 | private fun handleProjectSelection(runnableProject: RunnableProject) {
90 | if (!isLoaded) return
91 | reloadTfmSelector(runnableProject)
92 |
93 | environmentVariablesEditor.envs.set(runnableProject.environmentVariables.associate { it.key to it.value })
94 | }
95 |
96 | private fun handleChangeTfmSelection() {
97 | projectSelector.project.valueOrNull?.projectOutputs
98 | ?.singleOrNull { it.tfm?.presentableName == tfmSelector.string.valueOrNull }
99 | ?.let { projectOutput ->
100 | // Current tracking state
101 | val shouldChangeExePath = trackProjectExePath
102 | val shouldChangeWorkingDirectory = trackProjectWorkingDirectory
103 |
104 | // Tracked values
105 | if (shouldChangeExePath)
106 | exePathSelector.path.set(projectOutput.exePath)
107 |
108 | if (shouldChangeWorkingDirectory)
109 | workingDirectorySelector.path.set(projectOutput.workingDirectory)
110 |
111 | // Update default values (e.g. when folks reset the model)
112 | exePathSelector.defaultValue.set(projectOutput.exePath)
113 | workingDirectorySelector.defaultValue.set(projectOutput.workingDirectory)
114 | }
115 | }
116 |
117 | private fun reloadTfmSelector(runnableProject: RunnableProject) {
118 | tfmSelector.stringList.clear()
119 | runnableProject.projectOutputs.map { it.tfm?.presentableName ?: "" }.sorted().forEach {
120 | tfmSelector.stringList.add(it)
121 | }
122 | if (tfmSelector.stringList.isNotEmpty()) {
123 | tfmSelector.string.set(tfmSelector.stringList.first())
124 | }
125 | handleChangeTfmSelection()
126 | }
127 |
128 | private fun recalculateTrackProjectOutput() {
129 | val selectedProject = projectSelector.project.valueOrNull ?: return
130 | val selectedTfm = tfmSelector.string.valueOrNull ?: return
131 |
132 | selectedProject.projectOutputs.singleOrNull { it.tfm?.presentableName == selectedTfm }?.let { projectOutput ->
133 | trackProjectExePath = exePathSelector.path.value.isEmpty() || exePathSelector.path.value == projectOutput.exePath
134 | trackProjectWorkingDirectory = workingDirectorySelector.path.value.isEmpty() || workingDirectorySelector.path.value == projectOutput.workingDirectory
135 | }
136 | }
137 |
138 | fun reset(projectFilePath: String,
139 | trackProjectExePath: Boolean,
140 | trackProjectWorkingDirectory: Boolean,
141 | projectTfm: String,
142 | exePath: String,
143 | programParameters: String,
144 | workingDirectory: String,
145 | envs: Map,
146 | passParentEnvs: Boolean,
147 | useExternalConsole: Boolean,
148 | isUnloadedProject: Boolean,
149 | watchParameters: String,
150 | verbosity: DotNetWatchVerbosity,
151 | isSuppressHotReload: Boolean,
152 | isRestartOnRudeEdit: Boolean,
153 | isUsePollingFileWatcher: Boolean,
154 | isSuppressBrowserLaunch: Boolean,
155 | isSuppressBrowserRefresh: Boolean
156 | ) {
157 | fun resetProperties(exePath: String, programParameters: String, workingDirectory: String) {
158 | super.reset(
159 | exePath = exePath,
160 | programParameters = programParameters,
161 | workingDirectory = workingDirectory,
162 | envs = envs,
163 | isPassParentEnvs = passParentEnvs,
164 | runtime = null,
165 | runtimeOptions = "",
166 | useExternalConsole = useExternalConsole
167 | )
168 | }
169 |
170 | isLoaded = false
171 |
172 | this.trackProjectExePath = trackProjectExePath
173 | this.trackProjectWorkingDirectory = trackProjectWorkingDirectory
174 |
175 | watchParametersEditor.parametersString.set(watchParameters)
176 | verbosityEditor.rawValue.set(verbosity)
177 | isSuppressHotReloadEditor.isSelected.set(isSuppressHotReload)
178 | isRestartOnRudeEditEditor.isSelected.set(isRestartOnRudeEdit)
179 | isUsePollingFileWatcherEditor.isSelected.set(isUsePollingFileWatcher)
180 | isSuppressBrowserLaunchEditor.isSelected.set(isSuppressBrowserLaunch)
181 | isSuppressBrowserRefreshEditor.isSelected.set(isSuppressBrowserRefresh)
182 |
183 | runnableProjectsModel.projects.adviseOnce(lifetime) { projectList ->
184 |
185 | if (projectFilePath.isEmpty() || projectList.none {
186 | it.projectFilePath == projectFilePath && type.isApplicable(it.kind) }) {
187 |
188 | // Case when project is not selected - generate a fake entry
189 | if (projectFilePath.isEmpty() || !isUnloadedProject) {
190 | projectList.firstOrNull { type.isApplicable(it.kind) }?.let { project ->
191 | projectSelector.project.set(project)
192 | isLoaded = true
193 | handleProjectSelection(project)
194 | }
195 | } else {
196 | val fakeProjectName = File(projectFilePath).name
197 | val fakeProject = RunnableProject(
198 | fakeProjectName, fakeProjectName, projectFilePath, RunnableProjectKinds.Unloaded,
199 | listOf(
200 | ProjectOutput(
201 | RdTargetFrameworkId(RdVersionInfo(0, 0, 0), "", projectTfm, false, false), exePath,
202 | ParametersListUtil.parse(programParameters), workingDirectory, "", null, emptyList()
203 | )
204 | ),
205 | envs.map { EnvironmentVariable(it.key, it.value) }.toList(), null, listOf()
206 | )
207 | projectSelector.projectList.apply {
208 | clear()
209 | addAll(projectList + fakeProject)
210 | }
211 | projectSelector.project.set(fakeProject)
212 | reloadTfmSelector(fakeProject)
213 | resetProperties(
214 | exePath = exePath,
215 | programParameters = programParameters,
216 | workingDirectory = workingDirectory)
217 | }
218 | } else {
219 | projectList.singleOrNull {
220 | it.projectFilePath == projectFilePath && type.isApplicable(it.kind)
221 | }?.let { runnableProject ->
222 |
223 | projectSelector.project.set(runnableProject)
224 |
225 | // Set TFM
226 | reloadTfmSelector(runnableProject)
227 | val projectTfmExists = runnableProject.projectOutputs.any { it.tfm?.presentableName == projectTfm }
228 | val selectedTfm = if (projectTfmExists) projectTfm else runnableProject.projectOutputs.firstOrNull()?.tfm?.presentableName ?: ""
229 | tfmSelector.string.set(selectedTfm)
230 |
231 | // Set Project Output
232 | val projectOutput = runnableProject.projectOutputs.singleOrNull { it.tfm?.presentableName == selectedTfm }
233 | val effectiveExePath = projectOutput?.exePath ?: exePath
234 | val effectiveProgramParameters =
235 | if (projectOutput != null && projectOutput.defaultArguments.isNotEmpty()) {
236 | // https://github.com/maartenba/DotNetWatch/issues/9
237 | val defaultArguments = if (projectOutput.defaultArguments.firstOrNull()?.equals("--applicationpath", ignoreCase = true) == true)
238 | projectOutput.defaultArguments.drop(2)
239 | else
240 | projectOutput.defaultArguments
241 |
242 | ParametersListUtil.join(defaultArguments).replace("\\\"", "\"")
243 | } else if (programParameters.isNotEmpty()) {
244 | programParameters
245 | } else {
246 | // Handle the case when program parameters were set by changing TFM above and make sure it is not reset to empty.
247 | programParametersEditor.defaultValue.value
248 | }
249 |
250 | programParametersEditor.defaultValue.set(effectiveProgramParameters)
251 |
252 | val effectiveWorkingDirectory = projectOutput?.workingDirectory ?: workingDirectory
253 |
254 | // Reset properties
255 | resetProperties(
256 | exePath = effectiveExePath,
257 | programParameters = effectiveProgramParameters,
258 | workingDirectory = effectiveWorkingDirectory)
259 | }
260 | }
261 | isLoaded = true
262 | }
263 | }
264 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/jetbrains/advocates/rider/plugins/dotnetwatch/run/DotNetWatchVerbosity.kt:
--------------------------------------------------------------------------------
1 | package org.jetbrains.advocates.rider.plugins.dotnetwatch.run
2 |
3 | enum class DotNetWatchVerbosity(val argumentValue: String?) {
4 | NORMAL(null),
5 | QUIET("--quiet"),
6 | VERBOSE("--verbose")
7 | }
--------------------------------------------------------------------------------
/src/main/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.jetbrains.advocates.rider.plugins.dotnetwatch
4 | .NET Watch Run Configuration
5 | JetBrains Developer Advocates
6 |
7 | com.intellij.modules.rider
8 |
9 |
10 |
11 |
12 |
13 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/pluginIcon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/main/resources/icons/runConfiguration.svg:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/resources/messages/DotNetWatchBundle.properties:
--------------------------------------------------------------------------------
1 | name=DotNetWatch
2 |
3 | run.configuration.project.label=Project:
4 | run.configuration.tfm.label=Target framework:
5 | run.configuration.programParameters.label=Program arguments:
6 | run.configuration.workingDirectory.label=Working directory:
7 | run.configuration.environmentVariables.label=Environment variables:
8 | run.configuration.useExternalConsole.label=Use external console:
9 | run.configuration.separator.additional.label=dotnet-watch additional options
10 | run.configuration.watchParameters.label=Watch arguments:
11 | run.configuration.verbosity.label=Verbosity:
12 | run.configuration.verbosity.quiet=Quiet - Suppress all output except warnings and errors (--quiet)
13 | run.configuration.verbosity.normal=Normal
14 | run.configuration.verbosity.verbose=Verbose - Show verbose output (--verbose)
15 | run.configuration.isSuppressHotReload.label=Suppress hot reload:
16 | run.configuration.isRestartOnRudeEdit.label=Always restart on rude edit (6.0.2+)
17 | run.configuration.isUsePollingFileWatcher.label=Use polling file watcher:
18 | run.configuration.separator.browser.label=dotnet-watch browser options
19 | run.configuration.isSuppressBrowserLaunch.label=Suppress launching browser
20 | run.configuration.isSuppressBrowserRefresh.label=Suppress browser refresh
--------------------------------------------------------------------------------