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

🚚 Move to src + move to Solution target #8

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions Directory.Solution.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project>
<PropertyGroup>
<PnpmInstallCheck>$(SolutionDir)node_modules/.dotnet-pnpm-install</PnpmInstallCheck>
</PropertyGroup>

<!-- Install pnpm dependencies at solution/workspace level. -->
<Target Name="pnpm install" BeforeTargets="Restore"
Inputs="$(SolutionDir)package.json;$(SolutionDir)pnpm-lock.yaml;$(SolutionDir)pnpm-workspace.yaml"
Outputs="$(PnpmInstallCheck)"
>
<Exec Command="pnpm install --workspace-root" StandardOutputImportance="normal" />

<!-- Print restore message in similar way to csproj (no time though). -->
<Message Text="Restored $(SolutionDir)package.json (pnpm install)." Importance="high" />

<!-- File used for .NET iterative builds (touch updates the timestamp). -->
<Touch Files="$(PnpmInstallCheck)" AlwaysCreate="true" />
</Target>

<!-- Clean -->
<Target Name="Clean solution" AfterTargets="Clean">
<RemoveDir Directories="$(SolutionDir)artifacts" />
<RemoveDir Directories="$(PnpmInstallCheck)" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion client/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- Customize npm build -->
<PropertyGroup>
<!-- Skip npm install because we are using pnpm; see Directory.Build.targets -->
<!-- Skip npm install because we are using workspace; see Directory.Solution.targets -->
<ShouldRunNpmInstall>false</ShouldRunNpmInstall>
</PropertyGroup>

Expand Down
47 changes: 13 additions & 34 deletions client/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,32 @@
<PrettierArgs>--list-different --write</PrettierArgs>
</PropertyGroup>

<!-- Build: eslint -->
<Target Name="eslint" AfterTargets="Build">
<!-- Build order: tsc, eslint, prettier, and then any project-specific -->

<!-- Build: tsc -->
<Target Name="tsc" AfterTargets="Build">
<Exec
Command="pnpm exec eslint --format pretty $(EslintArgs) ."
Command="pnpm exec tsc --build"
StandardOutputImportance="normal"
/>
<!-- Print from tsc, similar to C# compile, for CLI consistency -->
<Message Text="$(ProjectName) -> $(WorkspaceRoot)artifacts/tsc/$(ProjectName)" Importance="high" />
</Target>

<!-- Build: prettier -->
<Target Name="prettier" AfterTargets="Build">
<!-- Build: eslint -->
<Target Name="eslint" AfterTargets="Build">
<Exec
Command="pnpm exec prettier --ignore-unknown $(PrettierArgs) ."
Command="pnpm exec eslint --format pretty $(EslintArgs) ."
StandardOutputImportance="normal"
/>
</Target>

<!-- Build: tsc -->
<Target Name="tsc" AfterTargets="Build">
<!-- Build: prettier -->
<Target Name="prettier" AfterTargets="Build">
<Exec
Command="pnpm exec tsc --build"
Command="pnpm exec prettier --ignore-unknown --cache-location $(WorkspaceRoot)artifacts/prettier $(PrettierArgs) ."
StandardOutputImportance="normal"
/>
<!-- Print from tsc, similar to C# compile, for CLI consistency -->
<Message Text="$(ProjectName) -> $(WorkspaceRoot)artifacts/tsc/$(ProjectName)" Importance="high" />
</Target>

<!-- Test: vitest -->
Expand All @@ -49,27 +51,4 @@
/>
<Message Text="Tests succeeded: '$(ProjectRoot)' [vitest]" Importance="high" />
</Target>

<!-- Restore: install -->
<!-- Hook into the JSPS restore before the standard NPMRestore -->
<Target Name="pnpm install" AfterTargets="NPMRestore"
Inputs="$(WorkspaceRoot)package.json;$(ProjectRoot)package.json"
Outputs="$(WorkspaceRoot)pnpm-lock.yaml"
>
<!-- Run pnpm install, timing it to match C# output -->
<PropertyGroup>
<StartTicks>$([System.DateTime]::UtcNow.Ticks)</StartTicks>
</PropertyGroup>

<Exec Command="pnpm -w install" StandardOutputImportance="normal" />

<PropertyGroup>
<FinishTicks>$([System.DateTime]::UtcNow.Ticks)</FinishTicks>
<ElapsedTicks>$([MSBuild]::Subtract($(FinishTicks), $(StartTicks)))</ElapsedTicks>
<Elapsed>$([System.TimeSpan]::FromTicks($(ElapsedTicks)).Milliseconds)</Elapsed>
</PropertyGroup>

<!-- Print restore message the same way as csproj -->
<Message Text="Restored $(MSBuildProjectFullPath) (in $(Elapsed) ms)." Importance="high" />
</Target>
</Project>
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions dotnet-with-esproj-example.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{161728
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
Workspace.props = Workspace.props
LICENSE = LICENSE
ci-build.ps1 = ci-build.ps1
Directory.Solution.targets = Directory.Solution.targets
LICENSE = LICENSE
.github\workflows\pipeline.yaml = .github\workflows\pipeline.yaml
Workspace.props = Workspace.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "projects", "projects", "{2E75741F-092F-4C2C-A182-AAF9F38CEC58}"
Expand Down