Skip to content

Commit 41eafa6

Browse files
authored
Merge branch 'main' into dfederm/official-builds
2 parents c91364d + e08ae70 commit 41eafa6

File tree

3 files changed

+206
-60
lines changed

3 files changed

+206
-60
lines changed

CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Contributing
2+
3+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
4+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
6+
7+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
8+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
9+
provided by the bot. You will only need to do this once across all repos using our CLA.
10+
11+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
12+
For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
13+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
14+
15+
## Setup
16+
17+
It is assumed that you are using VS v17.8 or later.
18+
19+
## Building
20+
21+
### Building MSBuildCache
22+
23+
You can build `MSBuildCache.sln` and/or open it in VS.
24+
25+
### Using a custom MSBuild (optional)
26+
27+
Clone the [MSBuild repo](https://github.com/dotnet/msbuild) adjacent to the MSBuildCache repo.
28+
29+
The remaining steps assume the `cwd` is the root of the MSBuildCache repo. You may need to adjust the paths if this is not the case.
30+
31+
Build the msbuild repo:
32+
```
33+
..\msbuild\build.cmd /p:CreateBootstrap=true /p:Configuration=Release
34+
```
35+
Note, MSBuild only needs to be built every time you update MSBuild, not every time you want to build MSBuildCache.
36+
37+
The path to MSBuild is: `..\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\amd64\MSBuild.exe`.
38+
39+
Note: when using a locally built MSBuild, many scenario may not work properly, for example C++ builds.
40+
41+
## Testing
42+
43+
### Running
44+
45+
Ensure you've built MSBuildCache as described above.
46+
47+
Now add the following package source to your test repo's `NuGet.config`:
48+
49+
```xml
50+
<add key="MSBuildCache" value="..\MSBuildCache\artifacts\Debug\Microsoft.MSBuildCache" />
51+
```
52+
53+
You may need to adjust the above path based on the paths to your test repo and MSBuildCache.
54+
55+
Finally, add a `PackageReference` to MSBuildCache to your test repo with version `*-*` to use the latest MSBuildCache version. This may look different from repo to repo, but here is an example:
56+
57+
```xml
58+
<PackageReference Include="Microsoft.MSBuildCache" VersionOverride="*-*" IncludeAssets="Analyzers;Build;BuildMultitargeting;BuildTransitive" PrivateAssets="All" />
59+
```
60+
61+
**NOTE!** Because you're using a locally built package, you may need to clear it from your package cache after each iteration via a command like `rmdir /S /Q %NUGET_PACKAGES%\Microsoft.MSBuildCache` (if you set `%NUGET_PACKAGES%`) or `rmdir /S /Q %USERPROFILE%\.nuget\packages\Microsoft.MSBuildCache` if you're using the dfault package cache location. Additionally, to ensure you're not using the head version of the package, you may need to create a branch and dummy commit locally to ensure the version is higher.
62+
63+
**NOTE!** MSBuildCache currently does not handle incremental builds well! The current target scenario is for CI environments, so **it's expected that the repo is always clean before building**. The main reason for this gap is because file probes and directory enumerations are not currently considered.
64+
65+
To enable file reporting via detours in MSBuild, ensure `/graph` and `/reportfileaccesses` are used.
66+
67+
Example of a set of commands to test MSBuildCache e2e in some repo:
68+
69+
```
70+
rmdir /S /Q %USERPROFILE%\.nuget\packages\Microsoft.MSBuildCache
71+
git clean -fdx
72+
<path-to-msbuild> /restore /graph /m /nr:false /reportfileaccesses
73+
```
74+
75+
Example of a set of commands to test MSBuildCache e2e in a subdirectory of some repo:
76+
77+
```
78+
rmdir /S /Q %USERPROFILE%\.nuget\packages\Microsoft.MSBuildCache
79+
pushd <repo-root>
80+
git clean -fdx
81+
popd
82+
<path-to-msbuild> /restore /graph /m /nr:false /reportfileaccesses
83+
```
84+
85+
### Settings
86+
87+
There is a built-in mechanism to passing settings to a plugin, which is to add metadata to the `ProjectCachePlugin` item. This is then exposed to the plugin via the `CacheContext` during initialialization.
88+
89+
To add additional settings, add it to [`PluginSettings`](src\Common\PluginSettings.cs) and [`Microsoft.MSBuildCache.Common.targets`](src\Common\build\Microsoft.MSBuildCache.Common.targets). By convention the MSBuild property name should be the setting name prefixed by "MSBuildCache".

0 commit comments

Comments
 (0)