在JetBrains Rider中,如何配置launchSettings.json排除测试项目构建?
解决launchSettings.json构建测试项目的问题
嗨,这个问题我之前也碰到过,其实只需要在你的Web配置项里加一个buildArguments参数就能搞定!
方法一:指定仅构建Web项目
直接在profiles下的Web节点里添加buildArguments,明确指定要构建的Web项目文件:
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:20169", "sslPort": 44329 } }, "profiles": { "Web": { "commandName": "Project", "launchBrowser": false, "applicationUrl": "http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Localhost" }, "buildArguments": "--project YourWebProject.csproj" } } }
把YourWebProject.csproj替换成你实际的Web项目文件名就行,如果项目不在解决方案根目录,记得加上相对路径(比如src/YourWebProject/YourWebProject.csproj)。
方法二:排除所有测试项目
如果你的测试项目都带有Test后缀(比如Xxx.Tests.csproj),可以用通配符直接排除它们:
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:20169", "sslPort": 44329 } }, "profiles": { "Web": { "commandName": "Project", "launchBrowser": false, "applicationUrl": "http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Localhost" }, "buildArguments": "--exclude **/*Test*.csproj" } } }
原理说明
默认情况下,Rider使用dotnet build命令时会构建整个解决方案,添加buildArguments后,会覆盖默认的构建参数——要么只构建指定的Web项目,要么直接排除测试项目,这样就不会再触发测试项目的构建流程了。
内容的提问来源于stack exchange,提问作者Node.JS
相关产品推荐
相关产品推荐

