diff --git a/build/Version.props b/build/Version.props
index 7007f9f..a9cfb3b 100644
--- a/build/Version.props
+++ b/build/Version.props
@@ -1,5 +1,5 @@
- 0.1.19262-alpha
+ 0.1.19317-alpha
diff --git a/src/dotnetCampus.SourceYard/Assets/Current/Core.targets b/src/dotnetCampus.SourceYard/Assets/Current/Core.targets
index c1a5bf8..efa5813 100644
--- a/src/dotnetCampus.SourceYard/Assets/Current/Core.targets
+++ b/src/dotnetCampus.SourceYard/Assets/Current/Core.targets
@@ -16,6 +16,7 @@
+
$(IntermediateOutputPath)SourcePacking\
@@ -35,8 +36,25 @@
$(SourcePackingDirectory)PackageReferenceVersionFile.txt
$(SourcePackingDirectory)SourceProjectPackageFile.txt
$(SourcePackingDirectory)SourceYardPackageReferenceFile.txt
+
+ $(SourcePackingDirectory)SourceYardCompilePackageFile.txt
+ $(SourcePackingDirectory)SourceYardResourcePackageFile.txt
+ $(SourcePackingDirectory)SourceYardContentPackageFile.txt
+ $(SourcePackingDirectory)SourceYardNonePackageFile.txt
+ $(SourcePackingDirectory)SourceYardEmbeddedResourcePackageFile.txt
+
+ <_SourceYardCompilePackage Include="%(SourceYardCompile.Identity)|%(SourceYardCompile.SourcePackagePath)"/>
+ <_SourceYardResourcePackage Include="%(SourceYardResource.Identity)|%(SourceYardResource.SourcePackagePath)"/>
+ <_SourceYardContentPackage Include="%(SourceYardContent.Identity)|%(SourceYardContent.SourcePackagePath)"/>
+ <_SourceYardNonePackage Include="%(SourceYardNone.Identity)|%(SourceYardNone.SourcePackagePath)"/>
+ <_SourceYardEmbeddedResourcePackage Include="%(SourceYardEmbeddedResource.Identity)|%(SourceYardEmbeddedResource.SourcePackagePath)"/>
+
+
+ <_SourceYardForSourceFusionCompilePackage Include="%(_SourceFusionIncludedCompileFile.Identity)|%(_SourceFusionIncludedCompileFile.Identity)"/>
+
+
--Authors "$(Authors)"
@@ -69,6 +87,7 @@
+
@@ -95,8 +114,19 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/dotnetCampus.SourceYard/Context/PackagedProjectFile.cs b/src/dotnetCampus.SourceYard/Context/PackagedProjectFile.cs
index a7c6118..0fe25df 100644
--- a/src/dotnetCampus.SourceYard/Context/PackagedProjectFile.cs
+++ b/src/dotnetCampus.SourceYard/Context/PackagedProjectFile.cs
@@ -12,62 +12,106 @@ namespace dotnetCampus.SourceYard.Context
class PackagedProjectFile
{
///
- public PackagedProjectFile(string compileFile, string resourceFile, string contentFile, string page, string applicationDefinition, string noneFile, string embeddedResource, string projectFolder)
+ public PackagedProjectFile(string compileFile, string resourceFile, string contentFile, string page,
+ string applicationDefinition, string noneFile, string embeddedResource, string projectFolder,
+ BuildProps buildProps)
{
_projectFolder = projectFolder;
+ _buildProps = buildProps;
ApplicationDefinition = applicationDefinition;
- CompileFileList = GetFileList(compileFile);
- ResourceFileList = GetFileList(resourceFile);
- ContentFileList = GetFileList(contentFile);
+ CompileFileList = GetSourceYardPackageFileList(compileFile, SourceYardCompilePackageFile);
+ ResourceFileList = GetSourceYardPackageFileList(resourceFile, SourceYardResourcePackageFile);
+ ContentFileList = GetSourceYardPackageFileList(contentFile, SourceYardContentPackageFile);
PageList = GetFileList(page);
- NoneFileList = GetFileList(noneFile);
- EmbeddedResourceList = GetFileList(embeddedResource);
+ NoneFileList = GetSourceYardPackageFileList(noneFile, SourceYardNonePackageFile);
+ EmbeddedResourceList = GetSourceYardPackageFileList(embeddedResource, SourceYardEmbeddedResourcePackageFile);
}
+ private const string
+ SourceYardCompilePackageFile = "SourceYardCompilePackageFile.txt",
+ SourceYardResourcePackageFile = "SourceYardResourcePackageFile.txt",
+ SourceYardContentPackageFile = "SourceYardContentPackageFile.txt",
+ SourceYardNonePackageFile = "SourceYardNonePackageFile.txt",
+ SourceYardEmbeddedResourcePackageFile = "SourceYardEmbeddedResourcePackageFile.txt";
+
///
/// 需要做源码包的项目的编译的文件
///
- public IReadOnlyList CompileFileList { get; }
+ public IReadOnlyList CompileFileList { get; }
///
/// 需要做源码包的项目的资源文件
///
- public IReadOnlyList ResourceFileList { get; }
+ public IReadOnlyList ResourceFileList { get; }
///
/// 需要做源码包项目的文件
///
- public IReadOnlyList ContentFileList { get; }
+ public IReadOnlyList ContentFileList { get; }
///
/// 需要做源码包项目的页面
///
- public IReadOnlyList PageList { get; }
+ public IReadOnlyList PageList { get; }
///
/// 嵌入文件
///
- public IReadOnlyList EmbeddedResourceList { get; }
+ public IReadOnlyList EmbeddedResourceList { get; }
///
/// 需要做源码包项目的文件
///
private string ApplicationDefinition { get; }
- public IReadOnlyList NoneFileList { get; }
+ public IReadOnlyList NoneFileList { get; }
- public IReadOnlyList GetAllFile()
+ public IReadOnlyList GetAllFile()
{
- return new CombineReadonlyList(CompileFileList, ResourceFileList, ContentFileList, PageList,
+ return new CombineReadonlyList(CompileFileList, ResourceFileList, ContentFileList,
+ PageList,
NoneFileList, EmbeddedResourceList);
}
- private List GetFileList(string file)
+ private List GetSourceYardPackageFileList(string file,
+ string sourceYardPackageFile)
+ {
+ sourceYardPackageFile = Path.Combine(_buildProps.SourcePackingDirectory, sourceYardPackageFile);
+ var sourceYardPackageFileList = ParseSourceYardPackageFile(sourceYardPackageFile);
+
+ var fileList = GetFileList(file);
+ return new CombineReadonlyList(sourceYardPackageFileList, fileList).Distinct(new SourceYardPackageFileEqualityComparer()).ToList();
+ }
+
+ private List ParseSourceYardPackageFile(string sourceYardPackageFile)
+ {
+ var sourceYardPackageFileList = new List();
+ var text = File.ReadAllText(sourceYardPackageFile);
+
+ foreach (var line in text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
+ {
+ var package = line.Split('|');
+ if (package.Length == 2)
+ {
+ var sourceFile = package[0];
+ var packagePath = package[1];
+
+ if (!string.IsNullOrEmpty(sourceFile))
+ {
+ sourceYardPackageFileList.Add(new SourceYardPackageFile(new FileInfo(sourceFile), packagePath));
+ }
+ }
+ }
+
+ return sourceYardPackageFileList;
+ }
+
+ private List GetFileList(string file)
{
if (string.IsNullOrEmpty(file) || !File.Exists(file))
{
- return new List();
+ return new List();
}
var fileList = File.ReadAllLines(file).ToList();
@@ -87,7 +131,7 @@ private List GetFileList(string file)
}
}
- return fileList;
+ return fileList.Select(temp => new SourceYardPackageFile(new FileInfo(temp), temp)).ToList();
}
private List RemoveTempFile(List fileList)
@@ -108,7 +152,8 @@ private List RemoveTempFile(List fileList)
return false;
});
- fileList.RemoveAll(temp => IgnoreFileEndList.Any(t => temp.EndsWith(t, StringComparison.OrdinalIgnoreCase)));
+ fileList.RemoveAll(temp =>
+ IgnoreFileEndList.Any(t => temp.EndsWith(t, StringComparison.OrdinalIgnoreCase)));
return fileList;
}
@@ -118,6 +163,8 @@ private List RemoveTempFile(List fileList)
///
private readonly string _projectFolder;
+ private readonly BuildProps _buildProps;
+
///
/// 忽略的文件夹列表
///
@@ -133,5 +180,18 @@ private List RemoveTempFile(List fileList)
{
".csproj.DotSettings", ".suo", ".user", ".sln.docstates", ".nupkg"
};
+
+ class SourceYardPackageFileEqualityComparer : IEqualityComparer
+ {
+ public bool Equals(SourceYardPackageFile x, SourceYardPackageFile y)
+ {
+ return x.SourceFile.FullName.Equals(y.SourceFile.FullName);
+ }
+
+ public int GetHashCode(SourceYardPackageFile obj)
+ {
+ return obj.SourceFile.FullName.GetHashCode();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/dotnetCampus.SourceYard/Context/SourceYardPackageFile.cs b/src/dotnetCampus.SourceYard/Context/SourceYardPackageFile.cs
new file mode 100644
index 0000000..3a4af46
--- /dev/null
+++ b/src/dotnetCampus.SourceYard/Context/SourceYardPackageFile.cs
@@ -0,0 +1,26 @@
+using System.IO;
+
+namespace dotnetCampus.SourceYard.Context
+{
+ ///
+ /// 放在源代码包的文件
+ ///
+ public class SourceYardPackageFile
+ {
+ public SourceYardPackageFile(FileInfo sourceFile, string sourcePackagePath)
+ {
+ SourceFile = sourceFile;
+ SourcePackagePath = sourcePackagePath;
+ }
+
+ ///
+ /// 源代码的文件
+ ///
+ public FileInfo SourceFile { get; }
+
+ ///
+ /// 打包的路径
+ ///
+ public string SourcePackagePath { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/dotnetCampus.SourceYard/Packer.cs b/src/dotnetCampus.SourceYard/Packer.cs
index 0628c6a..9d9d208 100644
--- a/src/dotnetCampus.SourceYard/Packer.cs
+++ b/src/dotnetCampus.SourceYard/Packer.cs
@@ -16,51 +16,52 @@ public Packer(string projectFile, string intermediateDirectory,
{
Logger = new Logger();
- Logger.Message("初始化打包");
+ Logger.Message(text: "初始化打包");
- if (string.IsNullOrEmpty(projectFile) || !File.Exists(projectFile))
+ if (string.IsNullOrEmpty(value: projectFile) || !File.Exists(path: projectFile))
{
- Logger.Error($"无法从{projectFile}找到项目文件");
+ Logger.Error(text: $"无法从{projectFile}找到项目文件");
return;
}
- if (string.IsNullOrEmpty(intermediateDirectory))
+ if (string.IsNullOrEmpty(value: intermediateDirectory))
{
// 这时的文件夹可以不存在
- Logger.Error("无法解析文件夹 " + intermediateDirectory);
+ Logger.Error(text: "无法解析文件夹 " + intermediateDirectory);
return;
}
- if (string.IsNullOrEmpty(packageOutputPath))
+ if (string.IsNullOrEmpty(value: packageOutputPath))
{
- Logger.Error("打包输出文件夹不能为空");
+ Logger.Error(text: "打包输出文件夹不能为空");
return;
}
- if (string.IsNullOrEmpty(packageVersion))
+ if (string.IsNullOrEmpty(value: packageVersion))
{
- Logger.Error("打包版本不能为空");
+ Logger.Error(text: "打包版本不能为空");
return;
}
- _projectFile = Path.GetFullPath(projectFile);
- _intermediateDirectory = Path.GetFullPath(intermediateDirectory);
- _packageOutputPath = Path.GetFullPath(packageOutputPath);
+ _projectFile = Path.GetFullPath(path: projectFile);
+ _intermediateDirectory = Path.GetFullPath(path: intermediateDirectory);
+ _packageOutputPath = Path.GetFullPath(path: packageOutputPath);
_packageVersion = packageVersion;
- _packageReferenceVersion = Path.GetFullPath(packageReferenceVersion);
+ _packageReferenceVersion = Path.GetFullPath(path: packageReferenceVersion);
BuildProps = buildProps;
PackageId = packageId;
PackagedProjectFile = new PackagedProjectFile
(
- compileFile: GetFile(compileFile),
- resourceFile: GetFile(resourceFile),
- contentFile: GetFile(contentFile),
- embeddedResource: GetFile(embeddedResource),
- page: GetFile(page),
- applicationDefinition: GetFile(applicationDefinition),
- noneFile: GetFile(noneFile),
- projectFolder: Path.GetDirectoryName(_projectFile)
+ compileFile: GetFile(file: compileFile),
+ resourceFile: GetFile(file: resourceFile),
+ contentFile: GetFile(file: contentFile),
+ embeddedResource: GetFile(file: embeddedResource),
+ page: GetFile(file: page),
+ applicationDefinition: GetFile(file: applicationDefinition),
+ noneFile: GetFile(file: noneFile),
+ projectFolder: Path.GetDirectoryName(path: _projectFile),
+ buildProps: buildProps
);
_packers = new IPackFlow[]
@@ -72,7 +73,7 @@ public Packer(string projectFile, string intermediateDirectory,
new NuGetPacker(),
};
- Logger.Message("初始化打包完成");
+ Logger.Message(text: "初始化打包完成");
}
internal void Pack()
diff --git a/src/dotnetCampus.SourceYard/Utils/BuildProps.cs b/src/dotnetCampus.SourceYard/Utils/BuildProps.cs
index e2d95a6..1600bd6 100644
--- a/src/dotnetCampus.SourceYard/Utils/BuildProps.cs
+++ b/src/dotnetCampus.SourceYard/Utils/BuildProps.cs
@@ -4,6 +4,7 @@
using System.Linq;
using dotnetCampus.Configurations;
using dotnetCampus.Configurations.Core;
+using dotnetCampus.SourceYard.Context;
namespace dotnetCampus.SourceYard.Utils
{
@@ -142,8 +143,10 @@ public void SetSourcePackingDirectory(string packingDirectory)
var sourceYardPackageReferenceFile = Path.Combine(packingDirectory, "SourceYardPackageReferenceFile.txt");
- List sourceYardPackageReferenceList = File.ReadAllLines(sourceYardPackageReferenceFile).Where(temp=>!string.IsNullOrEmpty(temp)).ToList();
+ List sourceYardPackageReferenceList = File.ReadAllLines(sourceYardPackageReferenceFile).Where(temp => !string.IsNullOrEmpty(temp)).ToList();
SourceYardPackageReferenceList = sourceYardPackageReferenceList;
+
+ var sourceYardCompilePackageFile = Path.Combine(packingDirectory, "SourceYardCompilePackageFile.txt");
}
///
diff --git a/src/dotnetCampus.SourceYard/Utils/FileSystem.cs b/src/dotnetCampus.SourceYard/Utils/FileSystem.cs
index 7c9156c..06946d7 100644
--- a/src/dotnetCampus.SourceYard/Utils/FileSystem.cs
+++ b/src/dotnetCampus.SourceYard/Utils/FileSystem.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using dotnetCampus.SourceYard.Context;
namespace dotnetCampus.SourceYard.Utils
{
@@ -14,19 +15,19 @@ internal static class FileSystem
///
///
///
- public static void CopyFileList(string sourceFolder, string targetFolder, List fileList)
+ public static void CopyFileList(string sourceFolder, string targetFolder, List fileList)
{
- foreach (var file in fileList.Select(Path.GetFullPath))
+ foreach (var file in fileList)
{
- var relativePath = MakeRelativePath(sourceFolder, file);
- var targetFile = Path.GetFullPath(Path.Combine(targetFolder, relativePath));
+ //var relativePath = MakeRelativePath(sourceFolder, file);
+ var targetFile = Path.GetFullPath(Path.Combine(targetFolder, file.SourcePackagePath));
var directory = Path.GetDirectoryName(targetFile);
if (directory != null && !Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
- File.Copy(file, targetFile, true);
+ File.Copy(file.SourceFile.FullName, targetFile, true);
}
}
diff --git a/src/dotnetCampus.SourceYard/Utils/ItemGroupElement.cs b/src/dotnetCampus.SourceYard/Utils/ItemGroupElement.cs
index c970a8b..5587f92 100644
--- a/src/dotnetCampus.SourceYard/Utils/ItemGroupElement.cs
+++ b/src/dotnetCampus.SourceYard/Utils/ItemGroupElement.cs
@@ -21,12 +21,18 @@ public ItemGroupElement(PackagedProjectFile contextPackagedProjectFile, string f
public (XElement itemGroupElement, XElement itemGroupElementOfXaml) GetItemGroup()
{
var contextPackagedProjectFile = _contextPackagedProjectFile;
- var compileFileList = contextPackagedProjectFile.CompileFileList;
- var contentFileList = contextPackagedProjectFile.ContentFileList;
- var resourceFileList = contextPackagedProjectFile.ResourceFileList;
- var noneFileList = contextPackagedProjectFile.NoneFileList;
- var embeddedResource = contextPackagedProjectFile.EmbeddedResourceList;
- var pageFileList = contextPackagedProjectFile.PageList;
+ var compileFileList = contextPackagedProjectFile.CompileFileList.Select(temp => temp.SourcePackagePath)
+ .ToList();
+ var contentFileList = contextPackagedProjectFile.ContentFileList.Select(temp => temp.SourcePackagePath)
+ .ToList();
+ var resourceFileList = contextPackagedProjectFile.ResourceFileList.Select(temp => temp.SourcePackagePath)
+ .ToList();
+ var noneFileList = contextPackagedProjectFile.NoneFileList.Select(temp => temp.SourcePackagePath)
+ .ToList();
+ var embeddedResource = contextPackagedProjectFile.EmbeddedResourceList.Select(temp => temp.SourcePackagePath)
+ .ToList();
+ var pageFileList = contextPackagedProjectFile.PageList.Select(temp => temp.SourcePackagePath)
+ .ToList();
var prefix = $"_{_packageGuid}";