mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
Fix casing problem
This commit is contained in:
parent
e9c65f6719
commit
16346a7743
@ -1,51 +0,0 @@
|
|||||||
using CapnpC.CSharp.Generator;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public class CsFileGeneratorResult
|
|
||||||
{
|
|
||||||
public CsFileGeneratorResult(FileGenerationResult generatorResult, string fileName, IReadOnlyList<CapnpMessage> messages)
|
|
||||||
{
|
|
||||||
if (generatorResult == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(generatorResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
Filename = fileName ?? throw new ArgumentNullException(nameof(fileName));
|
|
||||||
|
|
||||||
Error = generatorResult.Exception?.Message;
|
|
||||||
GeneratedCode = generatorResult.GeneratedContent;
|
|
||||||
Messages = messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CsFileGeneratorResult(string error)
|
|
||||||
{
|
|
||||||
Error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CsFileGeneratorResult(string error, IReadOnlyList<CapnpMessage> messages)
|
|
||||||
{
|
|
||||||
Error = error;
|
|
||||||
Messages = messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The error, if any.
|
|
||||||
/// </summary>
|
|
||||||
public string Error { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The generated code.
|
|
||||||
/// </summary>
|
|
||||||
public string GeneratedCode { get; }
|
|
||||||
|
|
||||||
public IReadOnlyList<CapnpMessage> Messages { get; }
|
|
||||||
|
|
||||||
public bool Success => Error == null;
|
|
||||||
|
|
||||||
public string Filename { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Security;
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
|||||||
using CapnpC.CSharp.Generator;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public class CapnpCodeBehindGenerator : IDisposable
|
|
||||||
{
|
|
||||||
|
|
||||||
public void InitializeProject(string projectPath)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public CsFileGeneratorResult GenerateCodeBehindFile(CapnpGenJob job)
|
|
||||||
{
|
|
||||||
string capnpFile = job.CapnpPath;
|
|
||||||
|
|
||||||
// Works around a weird capnp.exe behavior: When the input file is empty, it will spit out an exception dump
|
|
||||||
// instead of a parse error. But the parse error is nice because it contains a generated ID. We want the parse error!
|
|
||||||
// Workaround: Generate a temporary file that contains a single line break (such that it is not empty...)
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (File.Exists(capnpFile) && new FileInfo(capnpFile).Length == 0)
|
|
||||||
{
|
|
||||||
string tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".capnp");
|
|
||||||
|
|
||||||
File.WriteAllText(tempFile, Environment.NewLine);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var jobCopy = new CapnpGenJob()
|
|
||||||
{
|
|
||||||
CapnpPath = tempFile,
|
|
||||||
WorkingDirectory = job.WorkingDirectory
|
|
||||||
};
|
|
||||||
|
|
||||||
jobCopy.AdditionalArguments.AddRange(job.AdditionalArguments);
|
|
||||||
|
|
||||||
return GenerateCodeBehindFile(jobCopy);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
File.Delete(tempFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
var args = new List<string>();
|
|
||||||
args.AddRange(job.AdditionalArguments);
|
|
||||||
args.Add(capnpFile);
|
|
||||||
|
|
||||||
var result = CapnpCompilation.InvokeCapnpAndGenerate(args, job.WorkingDirectory);
|
|
||||||
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
if (result.GeneratedFiles.Count == 1)
|
|
||||||
{
|
|
||||||
return new CsFileGeneratorResult(
|
|
||||||
result.GeneratedFiles[0],
|
|
||||||
capnpFile + ".cs",
|
|
||||||
result.Messages);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new CsFileGeneratorResult(
|
|
||||||
"Code generation produced more than one file. This is not supported.",
|
|
||||||
result.Messages);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (result.ErrorCategory)
|
|
||||||
{
|
|
||||||
case CapnpProcessFailure.NotFound:
|
|
||||||
return new CsFileGeneratorResult("Unable to find capnp.exe - please install capnproto on your system first.");
|
|
||||||
|
|
||||||
case CapnpProcessFailure.BadInput:
|
|
||||||
return new CsFileGeneratorResult("Invalid schema", result.Messages);
|
|
||||||
|
|
||||||
case CapnpProcessFailure.BadOutput:
|
|
||||||
return new CsFileGeneratorResult(
|
|
||||||
"Internal error: capnp.exe produced a binary code generation request which was not understood by the backend",
|
|
||||||
result.Messages);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new NotSupportedException("Invalid error category");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Build.Framework;
|
|
||||||
using Microsoft.Build.Utilities;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public class CapnpFileCodeBehindGenerator : ICapnpcCsharpGenerator
|
|
||||||
{
|
|
||||||
public CapnpFileCodeBehindGenerator(TaskLoggingHelper log)
|
|
||||||
{
|
|
||||||
Log = log ?? throw new ArgumentNullException(nameof(log));
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskLoggingHelper Log { get; }
|
|
||||||
|
|
||||||
public IEnumerable<string> GenerateFilesForProject(
|
|
||||||
string projectPath,
|
|
||||||
List<CapnpGenJob> capnpFiles,
|
|
||||||
string projectFolder)
|
|
||||||
{
|
|
||||||
using (var capnpCodeBehindGenerator = new CapnpCodeBehindGenerator())
|
|
||||||
{
|
|
||||||
capnpCodeBehindGenerator.InitializeProject(projectPath);
|
|
||||||
|
|
||||||
var codeBehindWriter = new CodeBehindWriter(null);
|
|
||||||
|
|
||||||
if (capnpFiles == null)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var genJob in capnpFiles)
|
|
||||||
{
|
|
||||||
Log.LogMessage(MessageImportance.Normal, "Generate {0}, working dir = {1}, options = {2}",
|
|
||||||
genJob.CapnpPath,
|
|
||||||
genJob.WorkingDirectory,
|
|
||||||
string.Join(" ", genJob.AdditionalArguments));
|
|
||||||
|
|
||||||
var generatorResult = capnpCodeBehindGenerator.GenerateCodeBehindFile(genJob);
|
|
||||||
|
|
||||||
if (!generatorResult.Success)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(generatorResult.Error))
|
|
||||||
{
|
|
||||||
Log.LogError("{0}", generatorResult.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (generatorResult.Messages != null)
|
|
||||||
{
|
|
||||||
foreach (var message in generatorResult.Messages)
|
|
||||||
{
|
|
||||||
if (message.IsParseSuccess)
|
|
||||||
{
|
|
||||||
Log.LogError(
|
|
||||||
subcategory: null,
|
|
||||||
errorCode: null,
|
|
||||||
helpKeyword: null,
|
|
||||||
file: genJob.CapnpPath,
|
|
||||||
lineNumber: message.Line,
|
|
||||||
columnNumber: message.Column,
|
|
||||||
endLineNumber: message.Line,
|
|
||||||
endColumnNumber: message.EndColumn == 0 ? message.Column : message.EndColumn,
|
|
||||||
"{0}",
|
|
||||||
message.MessageText);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.LogError("{0}", message.FullMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var resultedFile = codeBehindWriter.WriteCodeBehindFile(generatorResult.Filename, generatorResult);
|
|
||||||
|
|
||||||
yield return FileSystemHelper.GetRelativePath(resultedFile, projectFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
|
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
|
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
|
||||||
|
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
|
||||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
|
||||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
|
||||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
|
||||||
<FileVersion>1.0.0.0</FileVersion>
|
|
||||||
<Version>1.0-local$([System.DateTime]::UtcNow.ToString(yyMMddHHmm))</Version>
|
|
||||||
|
|
||||||
<NuspecFile>$(MSBuildThisFileDirectory)CapnpC.CSharp.MsBuild.Generation.nuspec</NuspecFile>
|
|
||||||
<NuspecProperties>version=$(Version);configuration=$(Configuration)</NuspecProperties>
|
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
|
||||||
<PackageOutputPath>..\bin\$(Configuration)</PackageOutputPath>
|
|
||||||
<Configurations>Debug;Release</Configurations>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Composition" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem.SDK" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem.SDK.Tools" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Threading" />
|
|
||||||
<PackageReference Include="Microsoft.Xaml" />
|
|
||||||
<PackageReference Include="System.Collections.Immutable" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<PackageReference>
|
|
||||||
<PrivateAssets>All</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Build.Framework" Version="15.8.166" />
|
|
||||||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.8.166" />
|
|
||||||
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
|
|
||||||
<PackageReference Update="Microsoft.VisualStudio.Composition" Version="15.8.98" />
|
|
||||||
<PackageReference Update="Microsoft.VisualStudio.ProjectSystem" Version="15.8.243" />
|
|
||||||
<PackageReference Update="Microsoft.VisualStudio.ProjectSystem.SDK" Version="15.8.243" />
|
|
||||||
<PackageReference Update="Microsoft.VisualStudio.ProjectSystem.SDK.Tools" Version="15.8.243" />
|
|
||||||
<PackageReference Update="Microsoft.VisualStudio.Threading" Version="16.3.52" />
|
|
||||||
<PackageReference Update="Microsoft.Xaml" Version="4.0.0.1" />
|
|
||||||
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="FrameworkDependent\**\*.cs" />
|
|
||||||
<Compile Include="FrameworkDependent\*.cs" />
|
|
||||||
<None Include="FrameworkDependent\**\*.cs" />
|
|
||||||
<Compile Include="FrameworkDependent\FullFramework\**\*.cs" Condition="'$(TargetFramework)' == '$(CapnpcCsharp_FullFramework_Tools_TFM)'" />
|
|
||||||
<Compile Include="FrameworkDependent\DotNetCore\**\*.cs" Condition="'$(TargetFramework)' == '$(CapnpcCsharp_Core_Tools_TFM)'" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="FrameworkDependent\DotNetCore\" />
|
|
||||||
<Folder Include="FrameworkDependent\FullFramework\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CapnpC.CSharp.Generator\CapnpC.CSharp.Generator.csproj">
|
|
||||||
<Private>true</Private>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.Build">
|
|
||||||
<HintPath>Microsoft.Build</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Build.Framework">
|
|
||||||
<HintPath>Microsoft.Build.Framework</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Build.Utilities.Core">
|
|
||||||
<HintPath>Microsoft.Build.Utilities.Core</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.ComponentModel.Composition" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="buildMultiTargeting\CapnpC.CSharp.MsBuild.Generation.props">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CapnpC.CSharp.MsBuild.Generation.props">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CapnpC.CSharp.MsBuild.Generation.targets">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CapnpC.CSharp.MsBuild.Generation.tasks">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CPS\Buildsystem\CpsExtension.DesignTime.targets">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CPS\Buildsystem\Rules\CapnpFileType.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="build\CPS\Buildsystem\Rules\ProjectItemsSchema.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="rmdir /s /q $(SolutionDir)MsBuildGenerationTest\obj" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
|
||||||
<metadata>
|
|
||||||
<id>CapnpC.CSharp.MsBuild.Generation</id>
|
|
||||||
<version>$version$</version>
|
|
||||||
<title>CapnpC.CSharp.MsBuild.Generation</title>
|
|
||||||
<authors>Christian Köllner and contributors</authors>
|
|
||||||
<owners>Christian Köllner</owners>
|
|
||||||
<description>Package to enable the .capnp -> .cs file generation during build time</description>
|
|
||||||
<summary>Package to enable the .capnp -> .cs file generation during build time</summary>
|
|
||||||
<language>en-US</language>
|
|
||||||
<projectUrl>https://github.com/c80k/capnproto-dotnetcore</projectUrl>
|
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
||||||
<license type="expression">MIT</license>
|
|
||||||
<tags>capnproto csharp msbuild</tags>
|
|
||||||
<copyright>Christian Köllner and contributors</copyright>
|
|
||||||
<dependencies>
|
|
||||||
<dependency id="Capnp.Net.Runtime" version="1.0" />
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
<file src="build\**\*" target="build" />
|
|
||||||
<file src="buildMultiTargeting\**\*" target="buildMultiTargeting" />
|
|
||||||
<file src="bin\$configuration$\net471\*.dll" target="tasks\net471" />
|
|
||||||
<file src="bin\$configuration$\netcoreapp2.1\*.dll" target="tasks\netcoreapp2.1" />
|
|
||||||
<file src="bin\$configuration$\netcoreapp2.1\*.deps.json" target="tasks\netcoreapp2.1" />
|
|
||||||
|
|
||||||
<file src="..\Licenses\**\*" target="licenses" />
|
|
||||||
<file src="..\LICENSE" target="LICENSE" />
|
|
||||||
</files>
|
|
||||||
</package>
|
|
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.Build.Utilities;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public class CodeBehindWriter
|
|
||||||
{
|
|
||||||
public CodeBehindWriter(TaskLoggingHelper log)
|
|
||||||
{
|
|
||||||
Log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskLoggingHelper Log { get; }
|
|
||||||
|
|
||||||
public string WriteCodeBehindFile(string outputPath, CsFileGeneratorResult testFileGeneratorResult)
|
|
||||||
{
|
|
||||||
string directoryPath = Path.GetDirectoryName(outputPath) ?? throw new InvalidOperationException();
|
|
||||||
Log?.LogWithNameTag(Log.LogMessage, directoryPath);
|
|
||||||
|
|
||||||
Log?.LogWithNameTag(Log.LogMessage, $"Writing data to {outputPath}; path = {directoryPath}; generatedFilename = {testFileGeneratorResult.Filename}");
|
|
||||||
|
|
||||||
if (File.Exists(outputPath))
|
|
||||||
{
|
|
||||||
if (!FileSystemHelper.FileCompareContent(outputPath, testFileGeneratorResult.GeneratedCode))
|
|
||||||
{
|
|
||||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return outputPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public static class FileSystemHelper
|
|
||||||
{
|
|
||||||
public static void CopyFileToFolder(string filePath, string folderName)
|
|
||||||
{
|
|
||||||
File.Copy(filePath, Path.Combine(folderName, Path.GetFileName(filePath)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetRelativePath(string path, string basePath)
|
|
||||||
{
|
|
||||||
path = Path.GetFullPath(path);
|
|
||||||
basePath = Path.GetFullPath(basePath);
|
|
||||||
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase))
|
|
||||||
return "."; // the "this folder"
|
|
||||||
|
|
||||||
if (path.StartsWith(basePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
|
|
||||||
return path.Substring(basePath.Length + 1);
|
|
||||||
|
|
||||||
//handle different drives
|
|
||||||
string pathRoot = Path.GetPathRoot(path);
|
|
||||||
if (!String.Equals(pathRoot, Path.GetPathRoot(basePath), StringComparison.OrdinalIgnoreCase))
|
|
||||||
return path;
|
|
||||||
|
|
||||||
//handle ".." pathes
|
|
||||||
string[] pathParts = path.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
||||||
string[] basePathParts = basePath.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
||||||
|
|
||||||
int commonFolderCount = 0;
|
|
||||||
while (commonFolderCount < pathParts.Length && commonFolderCount < basePathParts.Length &&
|
|
||||||
String.Equals(pathParts[commonFolderCount], basePathParts[commonFolderCount], StringComparison.OrdinalIgnoreCase))
|
|
||||||
commonFolderCount++;
|
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for (int i = 0; i < basePathParts.Length - commonFolderCount; i++)
|
|
||||||
{
|
|
||||||
result.Append("..");
|
|
||||||
result.Append(Path.DirectorySeparatorChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pathParts.Length - commonFolderCount == 0)
|
|
||||||
return result.ToString().TrimEnd(Path.DirectorySeparatorChar);
|
|
||||||
|
|
||||||
result.Append(String.Join(Path.DirectorySeparatorChar.ToString(), pathParts, commonFolderCount, pathParts.Length - commonFolderCount));
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method accepts two strings the represent two files to
|
|
||||||
// compare. A return value of true indicates that the contents of the files
|
|
||||||
// are the same. A return value of any other value indicates that the
|
|
||||||
// files are not the same.
|
|
||||||
public static bool FileCompare(string filePath1, string filePath2)
|
|
||||||
{
|
|
||||||
int file1byte;
|
|
||||||
int file2byte;
|
|
||||||
|
|
||||||
// Determine if the same file was referenced two times.
|
|
||||||
if (String.Equals(filePath1, filePath2, StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
{
|
|
||||||
// Return true to indicate that the files are the same.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open the two files.
|
|
||||||
using (FileStream fs1 = new FileStream(filePath1, FileMode.Open, FileAccess.Read))
|
|
||||||
{
|
|
||||||
using (FileStream fs2 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
|
|
||||||
{
|
|
||||||
// Check the file sizes. If they are not the same, the files
|
|
||||||
// are not the same.
|
|
||||||
if (fs1.Length != fs2.Length)
|
|
||||||
{
|
|
||||||
// Return false to indicate files are different
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read and compare a byte from each file until either a
|
|
||||||
// non-matching set of bytes is found or until the end of
|
|
||||||
// file1 is reached.
|
|
||||||
do
|
|
||||||
{
|
|
||||||
// Read one byte from each file.
|
|
||||||
file1byte = fs1.ReadByte();
|
|
||||||
file2byte = fs2.ReadByte();
|
|
||||||
} while ((file1byte == file2byte) && (file1byte != -1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Return the success of the comparison. "file1byte" is
|
|
||||||
// equal to "file2byte" at this point only if the files are
|
|
||||||
// the same.
|
|
||||||
return ((file1byte - file2byte) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method accepts two strings the represent two files to
|
|
||||||
// compare. A return value of true indicates that the contents of the files
|
|
||||||
// are the same. A return value of any other value indicates that the
|
|
||||||
// files are not the same.
|
|
||||||
public static bool FileCompareContent(string filePath1, string fileContent)
|
|
||||||
{
|
|
||||||
var currentFileContent = File.ReadAllText(filePath1);
|
|
||||||
|
|
||||||
return string.CompareOrdinal(currentFileContent, fileContent) == 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Resources;
|
|
||||||
using Microsoft.Build.Framework;
|
|
||||||
using Microsoft.Build.Utilities;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public class GenerateCapnpFileCodeBehindTask : Task
|
|
||||||
{
|
|
||||||
public GenerateCapnpFileCodeBehindTask()
|
|
||||||
{
|
|
||||||
CodeBehindGenerator = new CapnpFileCodeBehindGenerator(Log);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICapnpcCsharpGenerator CodeBehindGenerator { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string ProjectPath { get; set; }
|
|
||||||
|
|
||||||
public string ProjectFolder => Path.GetDirectoryName(ProjectPath);
|
|
||||||
|
|
||||||
public ITaskItem[] CapnpFiles { get; set; }
|
|
||||||
|
|
||||||
[Output]
|
|
||||||
public ITaskItem[] GeneratedFiles { get; private set; }
|
|
||||||
|
|
||||||
static CapnpGenJob ToGenJob(ITaskItem item)
|
|
||||||
{
|
|
||||||
var job = new CapnpGenJob()
|
|
||||||
{
|
|
||||||
CapnpPath = item.GetMetadata("FullPath"),
|
|
||||||
WorkingDirectory = item.GetMetadata("WorkingDirectory")
|
|
||||||
};
|
|
||||||
|
|
||||||
string importPaths = item.GetMetadata("ImportPaths");
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(importPaths))
|
|
||||||
{
|
|
||||||
job.AdditionalArguments.AddRange(importPaths.Split(new char[] { ';' },
|
|
||||||
StringSplitOptions.RemoveEmptyEntries).Select(p => $"-I\"{p.TrimEnd('\\')}\""));
|
|
||||||
}
|
|
||||||
|
|
||||||
string sourcePrefix = item.GetMetadata("SourcePrefix");
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(sourcePrefix))
|
|
||||||
{
|
|
||||||
job.AdditionalArguments.Add(sourcePrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string verbose = item.GetMetadata("Verbose");
|
|
||||||
|
|
||||||
if ("true".Equals(verbose, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
job.AdditionalArguments.Add("--verbose");
|
|
||||||
}
|
|
||||||
|
|
||||||
return job;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Execute()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var currentProcess = Process.GetCurrentProcess();
|
|
||||||
|
|
||||||
Log.LogWithNameTag(Log.LogMessage, $"process: {currentProcess.ProcessName}, pid: {currentProcess.Id}, CD: {Environment.CurrentDirectory}");
|
|
||||||
|
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
|
||||||
{
|
|
||||||
Log.LogWithNameTag(Log.LogMessage, " " + assembly.FullName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.LogWithNameTag(Log.LogMessage, $"Error when dumping process info: {e}");
|
|
||||||
}
|
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
|
||||||
|
|
||||||
var generator = CodeBehindGenerator ?? new CapnpFileCodeBehindGenerator(Log);
|
|
||||||
|
|
||||||
Log.LogWithNameTag(Log.LogMessage, "Starting GenerateCapnpFileCodeBehind");
|
|
||||||
|
|
||||||
var capnpFiles = CapnpFiles?.Select(ToGenJob).ToList() ?? new List<CapnpGenJob>();
|
|
||||||
|
|
||||||
var generatedFiles = generator.GenerateFilesForProject(
|
|
||||||
ProjectPath,
|
|
||||||
capnpFiles,
|
|
||||||
ProjectFolder);
|
|
||||||
|
|
||||||
GeneratedFiles = generatedFiles.Select(file => new TaskItem { ItemSpec = file }).ToArray();
|
|
||||||
|
|
||||||
return !Log.HasLoggedErrors;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (e.InnerException != null)
|
|
||||||
{
|
|
||||||
if (e.InnerException is FileLoadException fle)
|
|
||||||
{
|
|
||||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException Filename: {fle.FileName}");
|
|
||||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException FusionLog: {fle.FusionLog}");
|
|
||||||
Log?.LogWithNameTag(Log.LogError, $"FileLoadException Message: {fle.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Log?.LogWithNameTag(Log.LogError, e.InnerException.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Log?.LogWithNameTag(Log.LogError, e.ToString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
|
||||||
{
|
|
||||||
Log.LogWithNameTag(Log.LogMessage, args.Name);
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Build.Utilities;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public static class LogExtensions
|
|
||||||
{
|
|
||||||
public static void LogWithNameTag(
|
|
||||||
this TaskLoggingHelper loggingHelper,
|
|
||||||
Action<string, object[]> loggingMethod,
|
|
||||||
string message,
|
|
||||||
params object[] messageArgs)
|
|
||||||
{
|
|
||||||
string fullMessage = $"[Cap'n Proto] {message}";
|
|
||||||
loggingMethod?.Invoke(fullMessage, messageArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace CapnpC.CSharp.MsBuild.Generation
|
|
||||||
{
|
|
||||||
public interface ICapnpcCsharpGenerator
|
|
||||||
{
|
|
||||||
IEnumerable<string> GenerateFilesForProject(string projectPath, List<CapnpGenJob> jobs, string projectFolder);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<CpsExtensionSchemaDirectory Condition="'$(CpsExtensionSchemaDirectory)' == ''">$(MSBuildThisFileDirectory)Rules\</CpsExtensionSchemaDirectory>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PropertyPageSchema Include="$(CpsExtensionSchemaDirectory)\ProjectItemsSchema.xaml;"/>
|
|
||||||
|
|
||||||
<PropertyPageSchema Include="$(CpsExtensionSchemaDirectory)\CapnpFileType.xaml;">
|
|
||||||
<Context>File;BrowseObject</Context>
|
|
||||||
</PropertyPageSchema>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,46 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
|
||||||
|
|
||||||
<Rule
|
|
||||||
Name="Capnp"
|
|
||||||
DisplayName="Cap'n Proto"
|
|
||||||
PageTemplate="tool"
|
|
||||||
Description="Cap'n Proto schema file"
|
|
||||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
|
||||||
|
|
||||||
<Rule.DataSource>
|
|
||||||
<DataSource Persistence="ProjectFile" HasConfigurationCondition="True" ItemType="CapnpFiles" />
|
|
||||||
</Rule.DataSource>
|
|
||||||
|
|
||||||
|
|
||||||
<StringProperty Name="Identity" DisplayName="File Name" ReadOnly="true" Category="Misc">
|
|
||||||
<StringProperty.DataSource>
|
|
||||||
<DataSource Persistence="Intrinsic" ItemType="CapnpFiles" PersistedName="Identity" />
|
|
||||||
</StringProperty.DataSource>
|
|
||||||
</StringProperty>
|
|
||||||
|
|
||||||
<StringProperty Name="FullPath" DisplayName="Full Path" ReadOnly="true" Category="Misc">
|
|
||||||
<StringProperty.DataSource>
|
|
||||||
<DataSource Persistence="Intrinsic" ItemType="CapnpFiles" PersistedName="FullPath" />
|
|
||||||
</StringProperty.DataSource>
|
|
||||||
</StringProperty>
|
|
||||||
|
|
||||||
<StringProperty Name="DependentUpon" Visible="false" />
|
|
||||||
<StringProperty Name="Link" Visible="false" />
|
|
||||||
<!--<StringProperty Name="Generator" Visible="true" DisplayName="Custom Tool"/>-->
|
|
||||||
|
|
||||||
<!--<BoolProperty Name="Exclude" DisplayName="Exclude from build" Category="Misc" Visible="True"
|
|
||||||
Description="Whether to skip code generation for this item"/>-->
|
|
||||||
|
|
||||||
<StringProperty Name="WorkingDirectory" DisplayName="Working Directory" ReadOnly="false" Category="Misc" Visible="True"
|
|
||||||
Subtype="Folder" Description="Working directory for capnp"/>
|
|
||||||
|
|
||||||
<StringListProperty Name="ImportPaths" DisplayName="Import Paths" Category="Misc" Visible="True" Subtype="Folder"
|
|
||||||
Description="List of directories searched for non-relative imports (ones that start with a '/')"/>
|
|
||||||
|
|
||||||
<StringProperty Name="SourcePrefix" DisplayName="Source Prefix" Switch="src-prefix" SwitchPrefix="--" Category="Misc" Visible="True"
|
|
||||||
Description="If a file specified for compilation starts with the specified prefix, remove the prefix for the purpose of deciding the names of output files."/>
|
|
||||||
|
|
||||||
<BoolProperty Name="Verbose" DisplayName="Verbose" Switch="verbose" SwitchPrefix="--" Category="Misc" Visible="True"
|
|
||||||
Description="Log informational messages to stderr; useful for debugging."/>
|
|
||||||
</Rule>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
|
||||||
<ProjectSchemaDefinitions
|
|
||||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
|
||||||
|
|
||||||
<ContentType
|
|
||||||
Name="CapnpFile"
|
|
||||||
DisplayName="CapnpFileType source file"
|
|
||||||
ItemType="CapnpFiles">
|
|
||||||
<NameValuePair Name="DependentExtensions" Value=".capnp.cs" />
|
|
||||||
</ContentType>
|
|
||||||
|
|
||||||
<ItemType Name="CapnpFiles" DisplayName="Cap'n Proto schema file"/>
|
|
||||||
|
|
||||||
<FileExtension Name=".capnp" ContentType="CapnpFile" />
|
|
||||||
|
|
||||||
</ProjectSchemaDefinitions>
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
|||||||
<Project TreatAsLocalProperty="TaskFolder;TaskAssembly">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<CapnpcCsharp_CpsExtensionDesignTimeTargetsPath Condition="'$(CapnpcCsharp_CpsExtensionDesignTimeTargetsPath)' == ''">$(MSBuildThisFileDirectory)CPS\Buildsystem\CpsExtension.DesignTime.targets</CapnpcCsharp_CpsExtensionDesignTimeTargetsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(CapnpcCsharp_CpsExtensionDesignTimeTargetsPath)" Condition="'$(DesignTimeBuild)' == 'true' " />
|
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<CapnpcCsharp_UseHostCompilerIfAvailable Condition="'$(CapnpcCsharp_UseHostCompilerIfAvailable)'==''">false</CapnpcCsharp_UseHostCompilerIfAvailable>
|
|
||||||
<UseHostCompilerIfAvailable>$(CapnpcCsharp_UseHostCompilerIfAvailable)</UseHostCompilerIfAvailable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)'==''">false</OverwriteReadOnlyFiles>
|
|
||||||
<ForceGeneration Condition="'$(ForceGeneration)'==''">false</ForceGeneration>
|
|
||||||
|
|
||||||
<ShowTrace Condition="'$(ShowTrace)'==''">false</ShowTrace>
|
|
||||||
<VerboseOutput Condition="'$(VerboseOutput)'==''">true</VerboseOutput>
|
|
||||||
<CapnpcCsharp_DebugMSBuildTask Condition="'$(CapnpcCsharp_DebugMSBuildTask)' == ''">false</CapnpcCsharp_DebugMSBuildTask>
|
|
||||||
|
|
||||||
<_CapnpcCsharpPropsImported Condition="'$(_CapnpcCsharpPropsImported)'==''">true</_CapnpcCsharpPropsImported>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
property group for feature flags
|
|
||||||
-->
|
|
||||||
<PropertyGroup>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
feature flag to enable experimental support for cleaning up generated code-behind files during rebuild and clean scenarios
|
|
||||||
-->
|
|
||||||
<CapnpcCsharp_DeleteCodeBehindFilesOnCleanRebuild Condition="'$(CapnpcCsharp_DeleteCodeBehindFilesOnCleanRebuild)'==''">false</CapnpcCsharp_DeleteCodeBehindFilesOnCleanRebuild>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
net.sdk support: feature flag to enable experimental support for net.sdk project system
|
|
||||||
-->
|
|
||||||
<CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)'==''">true</CapnpcCsharp_EnableDefaultCompileItems>
|
|
||||||
<CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile)'==''">$(CapnpcCsharp_EnableDefaultCompileItems)</CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile>
|
|
||||||
|
|
||||||
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.capnp</DefaultItemExcludes>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<CapnpFiles Include="**\*.capnp" >
|
|
||||||
<CodeBehindFile>%(RelativeDir)%(Filename).capnp.cs</CodeBehindFile>
|
|
||||||
<Visible>$(UsingMicrosoftNETSdk)</Visible>
|
|
||||||
<WorkingDirectory>$(ProjectDir)</WorkingDirectory>
|
|
||||||
</CapnpFiles>
|
|
||||||
|
|
||||||
<!-- obsolete codebehind files, scenarios:
|
|
||||||
- after rename operation
|
|
||||||
- after deletion of a feature file
|
|
||||||
- after pulling latest changes from version control with above changes
|
|
||||||
-->
|
|
||||||
<CapnpCsharpObsoleteCodeBehindFiles Include="**\*.capnp.cs" Exclude="@(CapnpFiles->'%(CodeBehindFile)')" />
|
|
||||||
|
|
||||||
<!-- Support for Visual Studio Incremental Build
|
|
||||||
https://github.com/techtalk/SpecFlow/issues/1319
|
|
||||||
-->
|
|
||||||
<UpToDateCheckInput Include="@(CapnpFiles)" />
|
|
||||||
<UpToDateCheckBuild Include="@(CapnpFiles->'%(CodeBehindFile)')" Original="@(CapnpFiles)" />
|
|
||||||
<CustomAdditionalCompileInputs Include="@(CapnpFiles->'%(CodeBehindFile)')" />
|
|
||||||
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<_CapnpcCsharp_TaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' And '$(_CapnpcCsharp_TaskFolder)' == ''">netcoreapp2.1</_CapnpcCsharp_TaskFolder>
|
|
||||||
<_CapnpcCsharp_TaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' And '$(_CapnpcCsharp_TaskFolder)' == ''">net471</_CapnpcCsharp_TaskFolder>
|
|
||||||
<_CapnpcCsharp_TaskAssembly Condition=" '$(_CapnpcCsharp_TaskAssembly)' == '' ">..\tasks\$(_CapnpcCsharp_TaskFolder)\CapnpC.CSharp.MsBuild.Generation.dll</_CapnpcCsharp_TaskAssembly>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="CapnpC.CSharp.MsBuild.Generation.tasks"/>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,133 +0,0 @@
|
|||||||
<Project>
|
|
||||||
|
|
||||||
<Import Project="CapnpC.CSharp.MsBuild.Generation.props" Condition="'$(_CapnpcCsharpPropsImported)'==''"/>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(BuildServerMode)' == ''">
|
|
||||||
<BuildServerMode Condition="'$(BuildingInsideVisualStudio)'=='true'">false</BuildServerMode>
|
|
||||||
<BuildServerMode Condition="'$(BuildingInsideVisualStudio)'!='true'">true</BuildServerMode>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
net.sdk experimental support:
|
|
||||||
- currently we only want to support either classic project system or netsdk project system.
|
|
||||||
- currently we don't want to support globbing with classic project system => ensure globbing only get enabled with 'UsingMicrosoftNETSdk'
|
|
||||||
- currently we are supporting $(EnableDefaultCompileItems) for disabling globbing support for codebehind files
|
|
||||||
-->
|
|
||||||
<_CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)' == '' And '$(UsingMicrosoftNETSdk)' == 'true'">true</_CapnpcCsharp_EnableDefaultCompileItems>
|
|
||||||
<_CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)' == 'true' And '$(UsingMicrosoftNETSdk)' == 'true'">true</_CapnpcCsharp_EnableDefaultCompileItems>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<BuildDependsOn>
|
|
||||||
BeforeUpdateCapnpFilesInProject;
|
|
||||||
UpdateCapnpFilesInProject;
|
|
||||||
IncludeCodeBehindFilesInProject;
|
|
||||||
AfterUpdateCapnpFilesInProject;
|
|
||||||
$(BuildDependsOn)
|
|
||||||
</BuildDependsOn>
|
|
||||||
<CleanDependsOn>
|
|
||||||
CleanCapnpFilesInProject;
|
|
||||||
$(CleanDependsOn)
|
|
||||||
</CleanDependsOn>
|
|
||||||
<RebuildDependsOn>
|
|
||||||
SwitchToForceGenerate;
|
|
||||||
$(RebuildDependsOn)
|
|
||||||
</RebuildDependsOn>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
net.sdk support: update default compile items to show generated files as nested items
|
|
||||||
-->
|
|
||||||
<ItemGroup Condition="'$(_CapnpcCsharp_EnableDefaultCompileItems)' == 'true' and '$(EnableDefaultItems)' == 'true' ">
|
|
||||||
<Compile Update="@(CapnpFiles->'%(CodeBehindFile)')"
|
|
||||||
DependentUpon="%(Filename)"
|
|
||||||
AutoGen="true"
|
|
||||||
DesignTime="true"
|
|
||||||
Visible="true"
|
|
||||||
Condition="'$(EnableDefaultCompileItems)' == 'true'" />
|
|
||||||
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<Target Name="WarnForCapnpCsharpCodeBehindFilesWithoutCorrespondingCapnpFile" AfterTargets="CoreCompile"
|
|
||||||
Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile)' == 'true'">
|
|
||||||
<Warning Text="For codebehind file '@(CapnpCsharpObsoleteCodeBehindFiles)', no capnp file was found." File="@(CapnpCsharpObsoleteCodeBehindFiles)" Condition="'@(CapnpCsharpObsoleteCodeBehindFiles)' != ''" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
|
|
||||||
<Target Name="SwitchToForceGenerate">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ForceGeneration>true</ForceGeneration>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
|
|
||||||
<Target Name="UpdateCapnpFilesInProject"
|
|
||||||
DependsOnTargets="BeforeUpdateCapnpFilesInProject">
|
|
||||||
|
|
||||||
<Message Text="CapnpFiles: @(CapnpFiles)" Importance="high" Condition="'$(VerboseOutput)' == 'true'" />
|
|
||||||
|
|
||||||
<GenerateCapnpFileCodeBehindTask
|
|
||||||
ProjectPath="$(MSBuildProjectFullPath)"
|
|
||||||
CapnpFiles="@(CapnpFiles)" >
|
|
||||||
|
|
||||||
<Output TaskParameter="GeneratedFiles" ItemName="CapnpcCsharpGeneratedFiles" />
|
|
||||||
</GenerateCapnpFileCodeBehindTask>
|
|
||||||
|
|
||||||
<Message Text="CapnpcCsharpGeneratedFiles: %(CapnpcCsharpGeneratedFiles.Identity)" Importance="high" Condition="'$(VerboseOutput)' == 'true'" />
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
net.sdk support: globbing does not support including files which are dynamically generated inside targets, we have to manually update compile items
|
|
||||||
-->
|
|
||||||
<ItemGroup Condition="'$(_CapnpcCsharp_EnableDefaultCompileItems)' == 'true' and '$(EnableDefaultItems)' == 'true' and '$(EnableDefaultCompileItems)' == 'true'">
|
|
||||||
|
|
||||||
<!-- if this is the first time generation of codebehind files, we have to manually add them as compile items -->
|
|
||||||
<Compile Include="@(CapnpFiles->'%(CodeBehindFile)')"
|
|
||||||
Exclude="@(Compile)"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
eather if codebehind files are added manually to compile item group or are added by net.sdk globbing support,
|
|
||||||
ensure they are nested under feature files like in previous specflow versions
|
|
||||||
currently, we cannot use itemgroup update attribute inside a target because of some bugs in MSBuild (all items will be updated)
|
|
||||||
- https://github.com/Microsoft/msbuild/issues/1618
|
|
||||||
- https://github.com/Microsoft/msbuild/issues/2835
|
|
||||||
- https://github.com/Microsoft/msbuild/issues/1124
|
|
||||||
-->
|
|
||||||
<Compile DependentUpon="@(CapnpFiles)"
|
|
||||||
AutoGen="true"
|
|
||||||
DesignTime="true"
|
|
||||||
Visible="true"
|
|
||||||
Condition="'%(Compile.Identity)' == '@(CapnpFiles->'%(CodeBehindFile)')'" />
|
|
||||||
|
|
||||||
<!-- remove files which got obsolete, typically after rename operation, or getting changes from source control -->
|
|
||||||
<Compile Remove="@(CapnpCsharpObsoleteCodeBehindFiles)" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="BeforeUpdateCapnpFilesInProject">
|
|
||||||
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="IncludeCodeBehindFilesInProject" DependsOnTargets="UpdateCapnpFilesInProject">
|
|
||||||
<ItemGroup Condition="'$(UsingMicrosoftNETSdk)' != 'true'">
|
|
||||||
<Compile Include="@(CapnpcCsharpGeneratedFiles)" Exclude="@(Compile)" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="AfterUpdateCapnpFilesInProject" DependsOnTargets="IncludeCodeBehindFilesInProject">
|
|
||||||
<!-- include any generated SpecFlow files in the compilation of the project if not included yet -->
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<Target Name="CleanCapnpFilesInProject" Condition="'$(CapnpcCsharp_DeleteCodeBehindFilesOnCleanRebuild)' == 'true'">
|
|
||||||
<!-- remove known codebehind files for existing capnp files -->
|
|
||||||
<Delete Files="%(CapnpFiles.CodeBehindFile)" ContinueOnError="true" />
|
|
||||||
|
|
||||||
<!-- remove obsolete codebehind files, scenarios:
|
|
||||||
- after rename operation
|
|
||||||
- after deletion of a capnp file
|
|
||||||
- after pulling latest changes from version control with above changes
|
|
||||||
-->
|
|
||||||
<Delete Files="@(CapnpCsharpObsoleteCodeBehindFiles)" ContinueOnError="true" />
|
|
||||||
</Target>
|
|
||||||
</Project>
|
|
@ -1,3 +0,0 @@
|
|||||||
<Project>
|
|
||||||
<UsingTask TaskName="CapnpC.CSharp.MsBuild.Generation.GenerateCapnpFileCodeBehindTask" AssemblyFile="$(_CapnpcCsharp_TaskAssembly)" />
|
|
||||||
</Project>
|
|
@ -1,5 +0,0 @@
|
|||||||
<Project TreatAsLocalProperty="TaskFolder;TaskAssembly">
|
|
||||||
|
|
||||||
<Import Project="..\build\CapnpC.CSharp.MsBuild.Generation.props"/>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
x
Reference in New Issue
Block a user