mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
MSBuild integration WIP
This commit is contained in:
parent
bf34494ae1
commit
6b81abb0f0
@ -4,12 +4,12 @@ using System.IO;
|
||||
|
||||
namespace Capnpc.Csharp.MsBuild.Generation
|
||||
{
|
||||
public class FeatureCodeBehindGenerator : IDisposable
|
||||
public class CapnpCodeBehindGenerator : IDisposable
|
||||
{
|
||||
//private SpecFlowProject _specFlowProject;
|
||||
//private ITestGenerator _testGenerator;
|
||||
|
||||
public void InitializeProject(string projectPath, string rootNamespace, IEnumerable<string> generatorPlugins)
|
||||
public void InitializeProject(string projectPath)
|
||||
{
|
||||
//_specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(Path.GetFullPath(projectPath), rootNamespace);
|
||||
|
||||
@ -21,14 +21,16 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
}
|
||||
|
||||
|
||||
public TestFileGeneratorResult GenerateCodeBehindFile(string featureFile)
|
||||
public TestFileGeneratorResult GenerateCodeBehindFile(string capnpFile)
|
||||
{
|
||||
//var featureFileInput = new FeatureFileInput(featureFile);
|
||||
//var generatedFeatureFileName = Path.GetFileName(_testGenerator.GetTestFullPath(featureFileInput));
|
||||
|
||||
//var testGeneratorResult = _testGenerator.GenerateTestFile(featureFileInput, new GenerationSettings());
|
||||
|
||||
return new TestFileGeneratorResult(null, null);
|
||||
return new TestFileGeneratorResult(
|
||||
new TestGeneratorResult() { GeneratedTestCode = "//dummy" },
|
||||
capnpFile + ".cs");
|
||||
}
|
||||
|
||||
public void Dispose()
|
@ -7,11 +7,11 @@ using Microsoft.Build.Utilities;
|
||||
|
||||
namespace Capnpc.Csharp.MsBuild.Generation
|
||||
{
|
||||
public class FeatureFileCodeBehindGenerator : ICapnpCsharpGenerator
|
||||
public class CapnpFileCodeBehindGenerator : ICapnpcCsharpGenerator
|
||||
{
|
||||
private readonly FilePathGenerator _filePathGenerator;
|
||||
|
||||
public FeatureFileCodeBehindGenerator(TaskLoggingHelper log)
|
||||
public CapnpFileCodeBehindGenerator(TaskLoggingHelper log)
|
||||
{
|
||||
Log = log ?? throw new ArgumentNullException(nameof(log));
|
||||
_filePathGenerator = new FilePathGenerator();
|
||||
@ -21,27 +21,24 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
public IEnumerable<string> GenerateFilesForProject(
|
||||
string projectPath,
|
||||
string rootNamespace,
|
||||
List<string> CapnpFiles,
|
||||
List<string> generatorPlugins,
|
||||
string projectFolder,
|
||||
string outputPath)
|
||||
List<string> capnpFiles,
|
||||
string projectFolder)
|
||||
{
|
||||
using (var featureCodeBehindGenerator = new FeatureCodeBehindGenerator())
|
||||
using (var capnpCodeBehindGenerator = new CapnpCodeBehindGenerator())
|
||||
{
|
||||
featureCodeBehindGenerator.InitializeProject(projectPath, rootNamespace, generatorPlugins);
|
||||
capnpCodeBehindGenerator.InitializeProject(projectPath);
|
||||
|
||||
var codeBehindWriter = new CodeBehindWriter(null);
|
||||
|
||||
if (CapnpFiles == null)
|
||||
if (capnpFiles == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var featureFile in CapnpFiles)
|
||||
foreach (var capnpFile in capnpFiles)
|
||||
{
|
||||
var featureFileItemSpec = featureFile;
|
||||
var generatorResult = featureCodeBehindGenerator.GenerateCodeBehindFile(featureFileItemSpec);
|
||||
var capnpFileItemSpec = capnpFile;
|
||||
var generatorResult = capnpCodeBehindGenerator.GenerateCodeBehindFile(capnpFileItemSpec);
|
||||
|
||||
if (!generatorResult.Success)
|
||||
{
|
||||
@ -63,11 +60,10 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
var targetFilePath = _filePathGenerator.GenerateFilePath(
|
||||
projectFolder,
|
||||
outputPath,
|
||||
featureFile,
|
||||
capnpFile,
|
||||
generatorResult.Filename);
|
||||
|
||||
var resultedFile = codeBehindWriter.WriteCodeBehindFile(targetFilePath, featureFile, generatorResult);
|
||||
var resultedFile = codeBehindWriter.WriteCodeBehindFile(targetFilePath, capnpFile, generatorResult);
|
||||
|
||||
yield return FileSystemHelper.GetRelativePath(resultedFile, projectFolder);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<NuspecFile>$(MSBuildThisFileDirectory)Capnpc.Csharp.MsBuild.Generation.nuspec</NuspecFile>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
@ -68,7 +68,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="build\CPS\Buildsystem\Rules\FeatureFileType.xaml">
|
||||
<None Update="build\CPS\Buildsystem\Rules\CapnpFileType.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<None Update="build\CPS\Buildsystem\Rules\ProjectItemsSchema.xaml">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Capnpc.Csharp.Generation</id>
|
||||
<id>Capnpc.Csharp.MsBuild.Generation</id>
|
||||
<version>1.0.0</version>
|
||||
<title>Capnpc.Csharp.MsBuild.Generation</title>
|
||||
<authors>Christian Köllner and contributors</authors>
|
||||
@ -20,7 +20,7 @@
|
||||
<files>
|
||||
<file src="build\**\*" target="build" />
|
||||
<file src="buildMultiTargeting\**\*" target="buildMultiTargeting" />
|
||||
<file src="bin\Release\netstandard2.0\*.dll" target="tasks\netstandard2.0" />
|
||||
<file src="bin\Release\net471\*.dll" target="tasks\net471" />
|
||||
<file src="bin\Release\netcoreapp2.1\*.dll" target="tasks\netcoreapp2.1" />
|
||||
<file src="bin\Release\netcoreapp2.1\*.deps.json" target="tasks\netcoreapp2.1" />
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
public TaskLoggingHelper Log { get; }
|
||||
|
||||
public string WriteCodeBehindFile(string outputPath, string featureFile, TestFileGeneratorResult testFileGeneratorResult) //todo needs unit tests
|
||||
public string WriteCodeBehindFile(string outputPath, string capnpFile, TestFileGeneratorResult testFileGeneratorResult)
|
||||
{
|
||||
//if (string.IsNullOrEmpty(testFileGeneratorResult.Filename))
|
||||
//{
|
||||
@ -21,27 +21,27 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//string directoryPath = Path.GetDirectoryName(outputPath) ?? throw new InvalidOperationException();
|
||||
//Log?.LogWithNameTag(Log.LogMessage, directoryPath);
|
||||
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}");
|
||||
Log?.LogWithNameTag(Log.LogMessage, $"Writing data to {outputPath}; path = {directoryPath}; generatedFilename = {testFileGeneratorResult.Filename}");
|
||||
|
||||
//if (File.Exists(outputPath))
|
||||
//{
|
||||
// if (!FileSystemHelper.FileCompareContent(outputPath, testFileGeneratorResult.GeneratedTestCode))
|
||||
// {
|
||||
// File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedTestCode);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (!Directory.Exists(directoryPath))
|
||||
// {
|
||||
// Directory.CreateDirectory(directoryPath);
|
||||
// }
|
||||
if (File.Exists(outputPath))
|
||||
{
|
||||
if (!FileSystemHelper.FileCompareContent(outputPath, testFileGeneratorResult.GeneratedCode))
|
||||
{
|
||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
|
||||
// File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedTestCode);
|
||||
//}
|
||||
File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode);
|
||||
}
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
|
@ -5,16 +5,16 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
{
|
||||
public class FilePathGenerator
|
||||
{
|
||||
public string GenerateFilePath(string projectFolder, string relativeOutputPath, string featureFileName, string generatedCodeBehindFileName)
|
||||
public string GenerateFilePath(string projectFolder, string capnpFileName, string generatedCodeBehindFileName)
|
||||
{
|
||||
if (projectFolder is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectFolder));
|
||||
}
|
||||
|
||||
if (featureFileName is null)
|
||||
if (capnpFileName is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(featureFileName));
|
||||
throw new ArgumentNullException(nameof(capnpFileName));
|
||||
}
|
||||
|
||||
if (generatedCodeBehindFileName is null)
|
||||
@ -22,7 +22,7 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
throw new ArgumentNullException(nameof(generatedCodeBehindFileName));
|
||||
}
|
||||
|
||||
string featureFileFullPath = Path.GetFullPath(Path.Combine(projectFolder, relativeOutputPath ?? "", featureFileName));
|
||||
string featureFileFullPath = Path.GetFullPath(Path.Combine(projectFolder, capnpFileName));
|
||||
string featureFileDirPath = Path.GetDirectoryName(featureFileFullPath);
|
||||
|
||||
return Path.Combine(featureFileDirPath, generatedCodeBehindFileName);
|
||||
|
@ -69,136 +69,44 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
// 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)
|
||||
using (FileStream fs2 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
// Return false to indicate files are different
|
||||
return false;
|
||||
// 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));
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
public static void CopyDirectory(string sourcePath, string destPath, bool cleanDestination = true)
|
||||
// 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)
|
||||
{
|
||||
if (cleanDestination)
|
||||
EnsureEmptyFolder(destPath);
|
||||
else
|
||||
{
|
||||
if (!Directory.Exists(destPath))
|
||||
{
|
||||
Directory.CreateDirectory(destPath);
|
||||
}
|
||||
}
|
||||
var currentFileContent = File.ReadAllText(filePath1);
|
||||
|
||||
foreach (string file in Directory.GetFiles(sourcePath))
|
||||
{
|
||||
var fileName = Path.GetFileName(file);
|
||||
Debug.Assert(fileName != null);
|
||||
string dest = Path.Combine(destPath, fileName);
|
||||
File.Copy(file, dest, true);
|
||||
File.SetAttributes(dest, File.GetAttributes(dest) & (~FileAttributes.ReadOnly));
|
||||
}
|
||||
return string.CompareOrdinal(currentFileContent, fileContent) == 0;
|
||||
|
||||
foreach (string folder in Directory.GetDirectories(sourcePath))
|
||||
{
|
||||
var folderName = Path.GetFileName(folder);
|
||||
Debug.Assert(folderName != null);
|
||||
string dest = Path.Combine(destPath, folderName);
|
||||
CopyDirectory(folder, dest);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureEmptyFolder(string folderName)
|
||||
{
|
||||
folderName = Path.GetFullPath(folderName);
|
||||
|
||||
if (!Directory.Exists(folderName))
|
||||
{
|
||||
Directory.CreateDirectory(folderName);
|
||||
return;
|
||||
}
|
||||
|
||||
DeleteFolderContent(folderName);
|
||||
}
|
||||
|
||||
public static void EnsureFolderOfFile(string filePath)
|
||||
{
|
||||
string directory = Path.GetDirectoryName(filePath);
|
||||
if (directory != null && !Directory.Exists(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
|
||||
private static void Retry(int number, Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
var i = number - 1;
|
||||
|
||||
if (i == 0)
|
||||
throw;
|
||||
|
||||
Retry(i, action);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteFolderContent(string folderName)
|
||||
{
|
||||
foreach (string file in Directory.GetFiles(folderName))
|
||||
{
|
||||
try
|
||||
{
|
||||
Retry(5, () => File.Delete(file));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Unable to delete file: " + file, ex);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string folder in Directory.GetDirectories(folderName))
|
||||
{
|
||||
try
|
||||
{
|
||||
Retry(5, () => Directory.Delete(folder, true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Unable to delete folder: " + folder, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteFolder(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
DeleteFolderContent(path);
|
||||
|
||||
Retry(5, () => Directory.Delete(path, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,18 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
{
|
||||
public GenerateCapnpFileCodeBehindTask()
|
||||
{
|
||||
CodeBehindGenerator = new FeatureFileCodeBehindGenerator(Log);
|
||||
CodeBehindGenerator = new CapnpFileCodeBehindGenerator(Log);
|
||||
}
|
||||
|
||||
public ICapnpCsharpGenerator CodeBehindGenerator { get; set; }
|
||||
public ICapnpcCsharpGenerator CodeBehindGenerator { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProjectPath { get; set; }
|
||||
|
||||
public string RootNamespace { get; set; }
|
||||
|
||||
public string ProjectFolder => Path.GetDirectoryName(ProjectPath);
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
public ITaskItem[] CapnpFiles { get; set; }
|
||||
|
||||
public ITaskItem[] GeneratorPlugins { get; set; }
|
||||
|
||||
[Output]
|
||||
public ITaskItem[] GeneratedFiles { get; private set; }
|
||||
|
||||
@ -55,21 +50,16 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
|
||||
var generator = CodeBehindGenerator ?? new FeatureFileCodeBehindGenerator(Log);
|
||||
var generator = CodeBehindGenerator ?? new CapnpFileCodeBehindGenerator(Log);
|
||||
|
||||
Log.LogWithNameTag(Log.LogMessage, "Starting GenerateFeatureFileCodeBehind");
|
||||
|
||||
var generatorPlugins = GeneratorPlugins?.Select(gp => gp.ItemSpec).ToList() ?? new List<string>();
|
||||
|
||||
var capnpFiles = CapnpFiles?.Select(i => i.ItemSpec).ToList() ?? new List<string>();
|
||||
|
||||
var generatedFiles = generator.GenerateFilesForProject(
|
||||
ProjectPath,
|
||||
RootNamespace,
|
||||
capnpFiles,
|
||||
generatorPlugins,
|
||||
ProjectFolder,
|
||||
OutputPath);
|
||||
ProjectFolder);
|
||||
|
||||
GeneratedFiles = generatedFiles.Select(file => new TaskItem { ItemSpec = file }).ToArray();
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace Capnpc.Csharp.MsBuild.Generation
|
||||
{
|
||||
public interface ICapnpCsharpGenerator
|
||||
public interface ICapnpcCsharpGenerator
|
||||
{
|
||||
IEnumerable<string> GenerateFilesForProject(string projectPath, string rootNamespace, List<string> CapnpFiles, List<string> generatorPlugins, string projectFolder, string outputPath);
|
||||
IEnumerable<string> GenerateFilesForProject(string projectPath, List<string> capnpFiles, string projectFolder);
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
|
||||
Errors = generatorResult.Errors;
|
||||
IsUpToDate = generatorResult.IsUpToDate;
|
||||
GeneratedTestCode = generatorResult.GeneratedTestCode;
|
||||
GeneratedCode = generatorResult.GeneratedTestCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -31,9 +31,9 @@ namespace Capnpc.Csharp.MsBuild.Generation
|
||||
public bool IsUpToDate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The generated test code.
|
||||
/// The generated code.
|
||||
/// </summary>
|
||||
public string GeneratedTestCode { get; }
|
||||
public string GeneratedCode { get; }
|
||||
|
||||
public bool Success => Errors == null || !Errors.Any();
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<ItemGroup>
|
||||
<PropertyPageSchema Include="$(CpsExtensionSchemaDirectory)\ProjectItemsSchema.xaml;"/>
|
||||
|
||||
<PropertyPageSchema Include="$(CpsExtensionSchemaDirectory)\FeatureFileType.xaml;">
|
||||
<PropertyPageSchema Include="$(CpsExtensionSchemaDirectory)\CapnpFileType.xaml;">
|
||||
<Context>File;BrowseObject</Context>
|
||||
</PropertyPageSchema>
|
||||
</ItemGroup>
|
||||
|
@ -2,10 +2,10 @@
|
||||
<!--Copyright, Microsoft Corporation, All rights reserved.-->
|
||||
|
||||
<Rule
|
||||
Name="Feature"
|
||||
DisplayName="Feature"
|
||||
Name="Capnp"
|
||||
DisplayName="Cap'n Proto"
|
||||
PageTemplate="tool"
|
||||
Description="SpecFlow Feature file"
|
||||
Description="Cap'n Proto schema file"
|
||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||
|
||||
<Rule.DataSource>
|
@ -4,15 +4,15 @@
|
||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||
|
||||
<ContentType
|
||||
Name="FeatureFile"
|
||||
DisplayName="FeatureFileType source file"
|
||||
Name="CapnpFile"
|
||||
DisplayName="CapnpFileType source file"
|
||||
ItemType="CapnpFiles">
|
||||
<NameValuePair Name="DependentExtensions" Value=".feature.cs" />
|
||||
|
||||
<NameValuePair Name="DependentExtensions" Value=".capnp.cs" />
|
||||
</ContentType>
|
||||
|
||||
<ItemType Name="CapnpFiles" DisplayName="Feature file"/>
|
||||
<ItemType Name="CapnpFiles" DisplayName="Cap'n Proto schema file"/>
|
||||
|
||||
<FileExtension Name=".feature" ContentType="FeatureFile" />
|
||||
<FileExtension Name=".capnp" ContentType="CapnpFile" />
|
||||
|
||||
</ProjectSchemaDefinitions>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<VerboseOutput Condition="'$(VerboseOutput)'==''">true</VerboseOutput>
|
||||
<CapnpcCsharp_DebugMSBuildTask Condition="'$(CapnpcCsharp_DebugMSBuildTask)' == ''">false</CapnpcCsharp_DebugMSBuildTask>
|
||||
|
||||
<_SpecFlowPropsImported Condition="'$(_SpecFlowPropsImported)'==''">true</_SpecFlowPropsImported>
|
||||
<_CapnpcCsharpPropsImported Condition="'$(_CapnpcCsharpPropsImported)'==''">true</_CapnpcCsharpPropsImported>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
@ -38,14 +38,14 @@
|
||||
net.sdk support: feature flag to enable experimental support for net.sdk project system
|
||||
-->
|
||||
<CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)'==''">true</CapnpcCsharp_EnableDefaultCompileItems>
|
||||
<CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile)'==''">$(CapnpcCsharp_EnableDefaultCompileItems)</CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile>
|
||||
<CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile)'==''">$(CapnpcCsharp_EnableDefaultCompileItems)</CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile>
|
||||
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.feature</DefaultItemExcludes>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.capnp</DefaultItemExcludes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<CapnpFiles Include="**\*.capnp" >
|
||||
<CodeBehindFile>%(RelativeDir)%(Filename).capnp(DefaultLanguageSourceExtension)</CodeBehindFile>
|
||||
<CodeBehindFile>%(RelativeDir)%(Filename).capnp.cs</CodeBehindFile>
|
||||
<Visible>$(UsingMicrosoftNETSdk)</Visible>
|
||||
</CapnpFiles>
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
- after deletion of a feature file
|
||||
- after pulling latest changes from version control with above changes
|
||||
-->
|
||||
<SpecFlowObsoleteCodeBehindFiles Include="**\*.capnp(DefaultLanguageSourceExtension)" Exclude="@(CapnpFiles->'%(CodeBehindFile)')" />
|
||||
<SpecFlowObsoleteCodeBehindFiles Include="**\*.capnp.cs" Exclude="@(CapnpFiles->'%(CodeBehindFile)')" />
|
||||
|
||||
<!-- Support for Visual Studio Incremental Build
|
||||
https://github.com/techtalk/SpecFlow/issues/1319
|
||||
@ -67,7 +67,7 @@
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<_CapnpcCsharp_TaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' And '$(_CapnpcCsharp_TaskFolder)' == ''">netcoreapp2.0</_CapnpcCsharp_TaskFolder>
|
||||
<_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>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
|
||||
<Import Project="Capnpc.Csharp.MsBuild.Generation.props" Condition="'$(_SpecFlowPropsImported)'==''"/>
|
||||
<Import Project="Capnpc.Csharp.MsBuild.Generation.props" Condition="'$(_CapnpcCsharpPropsImported)'==''"/>
|
||||
|
||||
<PropertyGroup Condition="'$(BuildServerMode)' == ''">
|
||||
<BuildServerMode Condition="'$(BuildingInsideVisualStudio)'=='true'">false</BuildServerMode>
|
||||
@ -49,8 +49,8 @@
|
||||
|
||||
|
||||
<Target Name="WarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile" AfterTargets="CoreCompile"
|
||||
Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingFeatureFile)' == 'true'">
|
||||
<Warning Text="For codebehind file '@(SpecFlowObsoleteCodeBehindFiles)', no feature file was found." File="@(SpecFlowObsoleteCodeBehindFiles)" Condition="'@(SpecFlowObsoleteCodeBehindFiles)' != ''" />
|
||||
Condition="'$(CapnpcCsharp_EnableWarnForFeatureCodeBehindFilesWithoutCorrespondingCapnpFile)' == 'true'">
|
||||
<Warning Text="For codebehind file '@(SpecFlowObsoleteCodeBehindFiles)', no capnp file was found." File="@(SpecFlowObsoleteCodeBehindFiles)" Condition="'@(SpecFlowObsoleteCodeBehindFiles)' != ''" />
|
||||
</Target>
|
||||
|
||||
|
||||
@ -66,26 +66,14 @@
|
||||
|
||||
<Message Text="CapnpFiles: @(CapnpFiles)" Importance="high" Condition="'$(VerboseOutput)' == 'true'" />
|
||||
|
||||
<Error
|
||||
Text="CapnpCsharp codebehind generation is not compatible with MSBuild codebehind generation. The custom tool must be removed from the file."
|
||||
File="@(None)"
|
||||
Condition="%(None.Extension) == '.feature' AND %(None.Generator) == 'SpecFlowSingleFileGenerator'"/>
|
||||
|
||||
<!-- <PropertyGroup>
|
||||
<SpecFlowCodeBehindOutputPath Condition="'$(SpecFlowCodeBehindOutputPath)' == ''">Features.Generated</SpecFlowCodeBehindOutputPath>
|
||||
</PropertyGroup> -->
|
||||
|
||||
<GenerateFeatureFileCodeBehindTask
|
||||
<GenerateCapnpFileCodeBehindTask
|
||||
ProjectPath="$(MSBuildProjectFullPath)"
|
||||
OutputPath="$(SpecFlowCodeBehindOutputPath)"
|
||||
CapnpFiles="@(CapnpFiles)"
|
||||
RootNamespace="$(RootNamespace)"
|
||||
GeneratorPlugins="@(SpecFlowGeneratorPlugins)" >
|
||||
CapnpFiles="@(CapnpFiles)" >
|
||||
|
||||
<Output TaskParameter="GeneratedFiles" ItemName="CapnpCsharpGeneratedFiles" />
|
||||
</GenerateFeatureFileCodeBehindTask>
|
||||
<Output TaskParameter="GeneratedFiles" ItemName="CapnpcCsharpGeneratedFiles" />
|
||||
</GenerateCapnpFileCodeBehindTask>
|
||||
|
||||
<Message Text="CapnpCsharpGeneratedFiles: %(CapnpCsharpGeneratedFiles.Identity)" Importance="high" Condition="'$(VerboseOutput)' == 'true'" />
|
||||
<Message Text="CapnpcCsharpGeneratedFiles: %(CapnpcCsharpGeneratedFiles.Identity)" Importance="high" Condition="'$(VerboseOutput)' == 'true'" />
|
||||
|
||||
|
||||
<!--
|
||||
@ -123,7 +111,7 @@
|
||||
|
||||
<Target Name="IncludeCodeBehindFilesInProject" DependsOnTargets="UpdateCapnpFilesInProject">
|
||||
<ItemGroup Condition="'$(UsingMicrosoftNETSdk)' != 'true'">
|
||||
<Compile Include="@(CapnpCsharpGeneratedFiles)" Exclude="@(Compile)" />
|
||||
<Compile Include="@(CapnpcCsharpGeneratedFiles)" Exclude="@(Compile)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
@ -132,12 +120,12 @@
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanCapnpFilesInProject" Condition="'$(CapnpcCsharp_DeleteCodeBehindFilesOnCleanRebuild)' == 'true'">
|
||||
<!-- remove known codebehind files for existing feature files -->
|
||||
<!-- 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 feature file
|
||||
- after deletion of a capnp file
|
||||
- after pulling latest changes from version control with above changes
|
||||
-->
|
||||
<Delete Files="@(SpecFlowObsoleteCodeBehindFiles)" ContinueOnError="true" />
|
||||
|
@ -1,3 +1,3 @@
|
||||
<Project>
|
||||
<UsingTask TaskName="Capnpc.Csharp.MsBuild.Generation.GenerateFeatureFileCodeBehindTask" AssemblyFile="$(_CapnpcCsharp_TaskAssembly)" />
|
||||
<UsingTask TaskName="Capnpc.Csharp.MsBuild.Generation.GenerateCapnpFileCodeBehindTask" AssemblyFile="$(_CapnpcCsharp_TaskAssembly)" />
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user