Skip to content

Commit

Permalink
Changes version to 0.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekspro committed Jun 22, 2024
1 parent 328bd28 commit f57e35c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
56 changes: 34 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ Setting `ExcludeAssets="runtime"` ensures the
**Pekspro.BuildInformationGenerator.Attributes.dll** file is not copied to your
build output (it is not required at runtime).


## Configuration

The `[BuildInformation]` attribute has a number of properties you can set to
control the generated class.

| Property | Description |
| ---------------------- | --------------------------------------------------- |
| `AddBuildTime` | Build time (in UTC). |
| `AddLocalBuildTime` | Local build time. |
| `AddAssemblyVersion` | Assembly version. |
| `AddOSVersion` | OS version of the machine where the build happens. |
| `AddGitCommitId` | Commit id. |
| `AddGitBranch` | Branch name. |
| `AddDotNetSdkVersion` | .NET SDK version. |
| Property | Description |
| ----------------------------- | --------------------------------------------------- |
| `AddBuildTime` | Build time (in UTC). |
| `AddLocalBuildTime` | Local build time. |
| `AddAssemblyVersion` | Assembly version. |
| `AddOSVersion` | OS version of the machine where the build happens. |
| `AddGitCommitId` | Commit id. |
| `AddGitBranch` | Branch name. |
| `AddDotNetSdkVersion` | .NET SDK version. |
| `AddWorkloadMauiVersion` | Workload for .NET MAUI. |
| `AddWorkloadWasmToolsVersion` | Workload for WebAssembly tools. |

Expand Down Expand Up @@ -167,9 +166,22 @@ static partial class BuildInfoAll
}
```

You can view your generated code by right clicking on your class name and selecting **Go to definition**.

Another option is to add this to your `.csproj` file:

```XML
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
```

You will then find the file in the `obj` directory.

### Performance

You can also specify if you want to have faked or real values:
You can specify if you want to have faked or real values:

| Property | Default | Description |
| --------------- | ------- | ------------------------------------- |
Expand All @@ -181,22 +193,22 @@ process. This should be fast, but probably nothing you want during normal
development. In Visual Studio, a source generator can be called very often
(every keystroke), so try to use fake values in development.

| Property | Data source |
| ---------------------- | --------------------------------------------------- |
| `BuildTime` | `DateTimeOffset`. |
| `LocalBuildTime` | `DateTimeOffset`. |
| `AssemblyVersion` | `AssemblyVersion` attribute. |
| `OSVersion` | `Environment.OSVersion`. |
| `Git.CommitId` | `AssemblyInformationalVersionAttribute` attribute, by default but also the **process** `git rev-parse HEAD` as a fallback. |
| `Git.Branch` | **Process** `git branch --show-current`. The environment variable `BUILD_SOURCEBRANCHNAME` might be used instead, that is automatically set in Azure Devops where git cannot be used to the the branch. |
| `DotNetSdkVersion` | **Process** `dotnet --version`. |
| `Workloads.MauiVersion` | **Process** `dotnet workload list`. |
| Property | Data source |
| ---------------------------- | --------------------------------------------------- |
| `BuildTime` | `DateTimeOffset`. |
| `LocalBuildTime` | `DateTimeOffset`. |
| `AssemblyVersion` | `AssemblyVersion` attribute. |
| `OSVersion` | `Environment.OSVersion`. |
| `Git.CommitId` | `AssemblyInformationalVersionAttribute` attribute, by default but also the **process** `git rev-parse HEAD` as a fallback. |
| `Git.Branch` | **Process** `git branch --show-current`. The environment variable `BUILD_SOURCEBRANCHNAME` might be used instead, that is automatically set in Azure Devops where git cannot be used to the the branch. |
| `DotNetSdkVersion` | **Process** `dotnet --version`. |
| `Workloads.MauiVersion` | **Process** `dotnet workload list`. |
| `Workloads.WasmToolsVersion` | **Process** `dotnet workload list` |

## Requirements

This source generator requires the .NET 7 SDK. You can target earlier frameworks
like .NET Core 3.1 etc, but the _SDK_ must be at least 7.0.100.
like .NET Core 3.1 etc, but the **SDK** must be at least 7.0.100.

## Credits

Expand Down
4 changes: 2 additions & 2 deletions Source/Library/Pekspro.BuildInformationGenerator/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Pekspro.BuildInformationGenerator;
public static class Constants
{
// Note. Should also be changed in Version.props.
public const string Version = "0.0.2-preview02";
//public const string Version = "0.1.0";
//public const string Version = "0.0.2-preview02";
public const string Version = "0.2.0";
}
2 changes: 1 addition & 1 deletion Source/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Note: Should also be changed in Constants.cs -->
<VersionPrefix>0.2.0</VersionPrefix>
<VersionSuffix>preview02</VersionSuffix>
<!--<VersionSuffix>preview02</VersionSuffix>-->
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
</PropertyGroup>
Expand Down

0 comments on commit f57e35c

Please sign in to comment.