Skip to content

Instantly share code, notes, and snippets.

@chirimenmonster
Last active June 15, 2020 06:45
Show Gist options
  • Save chirimenmonster/3c1303f230ca657ca1d77bec74846f2a to your computer and use it in GitHub Desktop.
Save chirimenmonster/3c1303f230ca657ca1d77bec74846f2a to your computer and use it in GitHub Desktop.
MSBuildでファイルから値を取得
#define NAME "Test"
#define VERSION "1.0.0"
#define DESCRIPTION "Test Data"
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Test">
<ReadLinesFromFile File="example.h">
<Output TaskParameter="Lines" PropertyName="DataFromFile" />
</ReadLinesFromFile>
<PropertyGroup>
<Version>$([System.Text.RegularExpressions.Regex]::Match($(DataFromFile), '#define\s+VERSION\s+\"(\d+\.\d+\.\d+)\"').Groups[1].Value)</Version>
</PropertyGroup>
<Message Text="Version = $(Version)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment