Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code Launchers & Tasks. #161

Merged
merged 5 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 15 additions & 38 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,23 @@
<!-- Step 1 Check if lockfile is properly restored -->
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
<NoWarn>$(NoWarn);NU1603;NU1604;NU1605;NU1608</NoWarn>
<NoWarn>$(NoWarn);NU1603</NoWarn>
</PropertyGroup>

<!-- Because ReadAllText is slow on osx/linux, try to find shasum and awk -->
<PropertyGroup>
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketRestoreCacheFile)" | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum "$(PaketLockFilePath)" | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
<PaketRestoreCachedHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreCachedHasher)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketRestoreCacheFile) | /usr/bin/awk '{ print $1 }'</PaketRestoreCachedHasher>
<PaketRestoreLockFileHasher Condition="'$(OS)' != 'Windows_NT' And '$(PaketRestoreLockFileHash)' == '' And Exists('/usr/bin/shasum') And Exists('/usr/bin/awk')">/usr/bin/shasum $(PaketLockFilePath) | /usr/bin/awk '{ print $1 }'</PaketRestoreLockFileHasher>
</PropertyGroup>

<!-- If shasum and awk exist get the hashes -->
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreCachedHasher)' != '' " Command="$(PaketRestoreCachedHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
</Exec>
<Exec StandardOutputImportance="Low" Condition=" '$(PaketRestoreLockFileHasher)' != '' " Command="$(PaketRestoreLockFileHasher)" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
</Exec>

<!-- Debug whats going on -->
<Message Importance="low" Text="calling paket restore with targetframework=$(TargetFramework) targetframeworks=$(TargetFrameworks)" />

<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<!-- if no hash has been done yet fall back to just reading in the files and comparing them -->
<PaketRestoreCachedHash Condition=" '$(PaketRestoreCachedHash)' == '' ">$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
Expand All @@ -72,22 +69,11 @@
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>

<PropertyGroup Condition="'$(PaketPropsVersion)' != '5.174.2' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
</PropertyGroup>

<!-- Do a global restore if required -->
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />

<!-- Step 2 Detect project specific changes -->
<ItemGroup>
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
<!-- Don't include all frameworks when msbuild explicitly asks for a single one -->
<MyTargetFrameworks Condition="'$(TargetFrameworks)' != '' AND '$(TargetFramework)' == '' " Include="$(TargetFrameworks)"></MyTargetFrameworks>
<PaketResolvedFilePaths Include="@(MyTargetFrameworks -> '$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).%(Identity).paket.resolved')"></PaketResolvedFilePaths>
</ItemGroup>
<Message Importance="low" Text="MyTargetFrameworks=@(MyTargetFrameworks) PaketResolvedFilePaths=@(PaketResolvedFilePaths)" />
<PropertyGroup>
<PaketReferencesCachedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
<!-- MyProject.fsproj.paket.references has the highest precedence -->
Expand All @@ -96,9 +82,7 @@
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
<!-- paket.references -->
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>

<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
<PaketResolvedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved</PaketResolvedFilePath>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
</PropertyGroup>
Expand All @@ -117,39 +101,32 @@
</PropertyGroup>

<!-- Step 2 b detect relevant changes in project file (new targetframework) -->
<PropertyGroup Condition=" '$(DoAllResolvedFilesExist)' != 'true' ">
<PropertyGroup Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)</PaketRestoreRequiredReason>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)'</PaketRestoreRequiredReason>
</PropertyGroup>

<!-- Step 3 Restore project specific stuff if required -->
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFrameworks)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' == '' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" --target-framework "$(TargetFramework)"' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(TargetFramework)' != '' " ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />

<!-- This shouldn't actually happen, but just to be sure. -->
<PropertyGroup>
<DoAllResolvedFilesExist>false</DoAllResolvedFilesExist>
<DoAllResolvedFilesExist Condition="Exists(%(PaketResolvedFilePaths.Identity))">true</DoAllResolvedFilesExist>
</PropertyGroup>
<Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' AND '$(ResolveNuGetPackages)' != 'False' " Text="Paket file '$(PaketResolvedFilePath)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />

<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
<ReadLinesFromFile Condition="Exists('$(PaketResolvedFilePath)')" File="$(PaketResolvedFilePath)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition="($(DesignTimeBuild) != true OR '$(PaketPropsLoaded)' != 'true') AND '@(PaketReferencesFileLines)' != '' " >
<ItemGroup Condition=" Exists('$(PaketResolvedFilePath)') AND '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
<Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>
<PrivateAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'true'">All</PrivateAssets>
</PackageReference>
</ItemGroup>

Expand Down Expand Up @@ -206,8 +183,8 @@

<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
</ConvertToAbsolutePath>

</ConvertToAbsolutePath>

<!-- Call Pack -->
<PackTask Condition="$(UseNewPack)"
Expand Down
5 changes: 5 additions & 0 deletions Content/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
"condition": "(server == \"saturn\" && remoting == false && deploy != \"azure\" && layout == \"none\" && reaction == false)",
"rename": { "paket_noazure_noremoting-nofulma-noreaction_saturn-noremoting-noazure.lock": "paket.lock" }
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was added by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urgh. sorry.

"include": "paket_noazure_noremoting-nofulma-noreaction_saturn-noremoting-noazure.lock",
"condition": "(server == \"saturn\" && remoting == false && deploy != \"azure\" && layout == \"none\" && reaction == false)",
"rename": { "paket_noazure_noremoting-nofulma-noreaction_saturn-noremoting-noazure.lock": "paket.lock" }
},
{
"include": "paket_noazure_noremoting-nofulma-reaction_saturn-noremoting-noazure.lock",
"condition": "(server == \"saturn\" && remoting == false && deploy != \"azure\" && layout == \"none\" && reaction == true)",
Expand Down
48 changes: 48 additions & 0 deletions Content/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build Server",
"program": "${workspaceFolder}/src/Server/bin/Debug/netcoreapp2.1/Server.dll",
"args": [],
"stopAtEntry": false,
"console": "internalConsole",
},
{
"name": "Debug Client",
"type": "chrome",
"request": "launch",
"preLaunchTask": "Watch Client",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src/Client",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///*": "${workspaceFolder}/*",
}
},
{
"name": "Watch SAFE App",
"type": "chrome",
"request": "launch",
"preLaunchTask": "Watch Client and Server",
"url": "http://localhost:8080",
"env": {
"vsCodeSession":"true"
},
"webRoot": "${workspaceFolder}/src/Client",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///*": "${workspaceFolder}/*",
}
}
],
"compounds": [
{
"name": "Debug SAFE App",
"configurations": [ "Debug Server", "Debug Client" ],
}
]
}
81 changes: 81 additions & 0 deletions Content/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Server",
"command": "dotnet",
"args": [ "build" ],
"type": "shell",
"options": { "cwd": "${workspaceFolder}/src/Server" },
"group": "build",
"problemMatcher": [ "$msCompile" ]
},
{
"label": "Watch Client and Server",
"command": "fake",
"args": [ "build", "-t", "Run" ],
"type": "shell",
"options": {
"cwd": "${workspaceFolder}",
"env": {
"vsCodeSession": "true"
}
},
"group": "build",
"isBackground": true,
"problemMatcher": {
"fileLocation": "absolute",
"background": {
"beginsPattern": { "regexp": "run Run" },
"endsPattern": { "regexp": "i 「wdm」: Compiled|The terminal process terminated" },
"activeOnStart": true
},
"pattern": {
"regexp": "^(.*)\\((\\d+),(\\d+)\\): \\((\\d+),(\\d+)\\) (warning|error) FABLE: (.*)$",
"file": 1,
"line": 2,
"column": 3,
"endLine": 4,
"endColumn": 5,
"severity": 6,
"message": 7
}
}
},
{
"label": "Watch Client",
"command": "fake",
"args": [ "build", "-t", "Run" ],
"type": "shell",
"options": {
"cwd": "${workspaceFolder}",
"env": {
"vsCodeSession": "true",
"safeClientOnly": "true"
}
},
"group": "build",
"isBackground": true,
"problemMatcher": {
"fileLocation": "absolute",
"background": {
"beginsPattern": { "regexp": "run Run" },
"endsPattern": { "regexp": "i 「wdm」: Compiled|The terminal process terminated" },
"activeOnStart": true
},
"pattern": {
"regexp": "^(.*)\\((\\d+),(\\d+)\\): \\((\\d+),(\\d+)\\) (warning|error) FABLE: (.*)$",
"file": 1,
"line": 2,
"column": 3,
"endLine": 4,
"endColumn": 5,
"severity": 6,
"message": 7
}
}
}
]
}
32 changes: 13 additions & 19 deletions Content/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,23 @@ Target.create "InstallClient" (fun _ ->
runDotNet "restore" clientPath
)

Target.create "RestoreServer" (fun _ ->
runDotNet "restore" serverPath
)

Target.create "Build" (fun _ ->
runDotNet "build" serverPath
runDotNet "fable webpack-cli -- --config src/Client/webpack.config.js -p" clientPath
)

Target.create "Run" (fun _ ->
let server = async {
runDotNet "watch run" serverPath
}
let client = async {
runDotNet "fable webpack-dev-server -- --config src/Client/webpack.config.js" clientPath
}
let browser = async {
do! Async.Sleep 5000
openBrowser "http://localhost:8080"
}

[ server; client; browser ]
Target.create "Run" (fun p ->
let vsCodeSession = Environment.hasEnvironVar "vsCodeSession"
let safeClientOnly = Environment.hasEnvironVar "safeClientOnly"

let tasks =
[ if not safeClientOnly then yield async { runDotNet "watch run" serverPath }
yield async { runDotNet "fable webpack-dev-server -- --config src/Client/webpack.config.js" clientPath }
if not vsCodeSession then
yield async {
do! Async.Sleep 5000
openBrowser "http://localhost:8080" } ]

tasks
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
Expand Down Expand Up @@ -224,7 +219,6 @@ open Fake.Core.TargetOperators

"Clean"
==> "InstallClient"
==> "RestoreServer"
==> "Run"

Target.runOrDefaultWithArguments "Build"