Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ho-cooh/msbuild-inline-task-demo
A demo about running C# code in msbuild
https://github.com/ho-cooh/msbuild-inline-task-demo
csharp csproj dotnet msbuild nuget vcxproj visual-studio
Last synced: about 2 months ago
JSON representation
A demo about running C# code in msbuild
- Host: GitHub
- URL: https://github.com/ho-cooh/msbuild-inline-task-demo
- Owner: HO-COOH
- Created: 2023-10-15T18:02:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-16T18:18:58.000Z (over 1 year ago)
- Last Synced: 2024-10-30T08:23:46.783Z (3 months ago)
- Topics: csharp, csproj, dotnet, msbuild, nuget, vcxproj, visual-studio
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MSBuild Inline Task demo
This demo shows how to display a WPF window using `MSBuild` files only.
The real usage is to modify stuff with C# code during build process, which you can utilize from a nuget library that you automatically modify something in the consuming project after installing it.## How?
### Using directly in build file (`csproj` / `vcxproj`)
- Define a `UsingTask` to a `.targets` or `.vcxproj` or `.csproj` file
```xml
```
- Add a `` in that same file, and the thing inside it **varies** depending on your project type, if it's a C++ project (`.vcxproj` file), the following code execute the code **before** builds.
```xml
$(BeforeMidlCompileTargets);
Demo
```
### Using with `.targets` file
Just add a `` node as a child of the `` (which will be automatically added if there is one in your nuget package).
```xml
```
## Result
Open a `Developer Powershell`, run `msbuild.exe`, and you shall see this.
![image](https://github.com/HO-COOH/MsBuild-Inline-Task-Demo/assets/42881734/bf728bc8-b6a7-45b0-b452-94601f7be8e6)## More info
- [msbuild file schema](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-project-file-schema-reference?view=vs-2022)
- [The very hard to find msbuild api doc](https://learn.microsoft.com/en-us/dotnet/api/?view=msbuild-17-netcore)