<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <VersionTxt>$(RepoRoot)\version.txt</VersionTxt>
    <GlobalAssemblyVersionInfoPath>$(SrcManagedRoot)\GlobalAssemblyVersionInfo.cs</GlobalAssemblyVersionInfoPath>
    <UnmanagedVersionPath>$(RepoRoot)\src\unmanaged\version.h</UnmanagedVersionPath>
  </PropertyGroup>
  
  <Target Name="GenerateVersionFiles" BeforeTargets="CoreCompile" Inputs="$(VersionTxt)" Outputs="$(GlobalAssemblyVersionInfoPath);$(UnmanagedVersionPath)">
    <ReadLinesFromFile File="$(VersionTxt)">
      <Output TaskParameter="Lines" ItemName="VersionTextLines"/>
    </ReadLinesFromFile>
    <PropertyGroup>
      <BuildVersion>@(VersionTextLines)</BuildVersion>
    </PropertyGroup>
    <WriteLinesToFile File="$(GlobalAssemblyVersionInfoPath)" Lines="[assembly: System.Reflection.AssemblyVersion(&quot;$(BuildVersion)&quot;)];[assembly: System.Reflection.AssemblyFileVersion(&quot;$(BuildVersion)&quot;)]" Overwrite="true" />
    <WriteLinesToFile File="$(UnmanagedVersionPath)" Lines="#define FILE_VERSION $(BuildVersion.Replace(&quot;.&quot;,&quot;,&quot;));#define PRODUCT_VERSION $(BuildVersion)" Overwrite="true" />
    <ItemGroup>
      <Compile Condition="Exists('$(GlobalAssemblyVersionInfoPath)')" Include="$(GlobalAssemblyVersionInfoPath)" />
    </ItemGroup>
  </Target>

  <!-- Google Blogger -->

  <PropertyGroup>
    <BloggerClientSecretsJson>$(RepoRoot)\src\managed\OpenLiveWriter.BlogClient\Clients\GoogleBloggerv3Secrets.json</BloggerClientSecretsJson>
    <OlwBloggerClientId Condition="'$(OlwBloggerClientId)'==''">PASTE_YOUR_CLIENT_ID_HERE</OlwBloggerClientId>
    <OlwBloggerClientSecret Condition="'$(OlwBloggerClientSecret)'==''">PASTE_YOUR_CLIENT_SECRET_HERE</OlwBloggerClientSecret>
  </PropertyGroup>

  <Target Name="GenerateBloggerClientSecrets" BeforeTargets="CoreCompile" Inputs="$(MSBuildThisFileFullPath)" Outputs="$(BloggerClientSecretsJson)">
    <Message Text="$(BloggerClientSecretsJson)" Importance="high" />
    <WriteLinesToFile File="$(BloggerClientSecretsJson)" Lines="{ &quot;installed&quot;: { &quot;client_id&quot;: &quot;$(OlwBloggerClientId)&quot;, &quot;client_secret&quot;: &quot;$(OlwBloggerClientSecret)&quot; } }" Overwrite="true" />
  </Target>

</Project>
