From a0afe69fba191c0d1900209c2e1d302c4a5a4b37 Mon Sep 17 00:00:00 2001 From: lindexi Date: Sat, 23 May 2020 11:40:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E6=B7=BB=E5=8A=A0tag?= =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/PublishNuget.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/PublishNuget.yml b/.github/workflows/PublishNuget.yml index 37a208d..18db953 100644 --- a/.github/workflows/PublishNuget.yml +++ b/.github/workflows/PublishNuget.yml @@ -2,8 +2,8 @@ name: publish nuget on: push: - branches: - - master + tags: + - '*' jobs: build: @@ -16,7 +16,14 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.201 + dotnet-version: 3.1.202 + + - name: Install tool + run: dotnet install -g dotnetCampus.TagToVersion + + - name: Set tag to version + run: dotnet TagToVersion -t ${{ github.ref }} + - name: Build with dotnet run: dotnet build --configuration Release - name: Install Nuget From 3de5ad3ec2bb27d04647ef8bd2b38b5499024aba Mon Sep 17 00:00:00 2001 From: lindexi Date: Sat, 23 May 2020 11:44:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/PublishNuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PublishNuget.yml b/.github/workflows/PublishNuget.yml index 18db953..e3c0f01 100644 --- a/.github/workflows/PublishNuget.yml +++ b/.github/workflows/PublishNuget.yml @@ -19,7 +19,7 @@ jobs: dotnet-version: 3.1.202 - name: Install tool - run: dotnet install -g dotnetCampus.TagToVersion + run: dotnet tool install -g dotnetCampus.TagToVersion - name: Set tag to version run: dotnet TagToVersion -t ${{ github.ref }} From 786e20cdf59917e00a87366ee4c59afb07145ac4 Mon Sep 17 00:00:00 2001 From: lindexi Date: Sun, 14 Jun 2020 17:37:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=BA=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8C=85=E8=A2=AB=E7=9B=AE=E6=A0=87=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=BA=86=EF=BC=8C=E6=89=93=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=BA=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8C=85=E5=B0=86=E4=BC=9A=E5=8C=85=E5=90=AB=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 尝试修复 #60 --- build/Version.props | 2 +- .../Assets/Current/Core.targets | 3 +- .../Assets/Target/build/$(PackageId).props | 3 ++ .../PackFlow/NuspecFileGenerator.cs | 42 ++++++++++++------- .../Utils/BuildProps.cs | 11 +++++ 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/build/Version.props b/build/Version.props index f62feed..783a115 100644 --- a/build/Version.props +++ b/build/Version.props @@ -1,5 +1,5 @@ - 0.1.19031-alpha + 0.1.19051-alpha diff --git a/src/dotnetCampus.SourceYard/Assets/Current/Core.targets b/src/dotnetCampus.SourceYard/Assets/Current/Core.targets index a24a3a1..a88007a 100644 --- a/src/dotnetCampus.SourceYard/Assets/Current/Core.targets +++ b/src/dotnetCampus.SourceYard/Assets/Current/Core.targets @@ -33,6 +33,7 @@ $(SourcePackingDirectory)PackageReferenceVersionFile.txt $(SourcePackingDirectory)SourceProjectPackageFile.txt + $(SourcePackingDirectory)SourceYardPackageReferenceFile.txt @@ -98,7 +99,7 @@ - + diff --git a/src/dotnetCampus.SourceYard/Assets/Target/build/$(PackageId).props b/src/dotnetCampus.SourceYard/Assets/Target/build/$(PackageId).props index da3711e..c0c58f9 100644 --- a/src/dotnetCampus.SourceYard/Assets/Target/build/$(PackageId).props +++ b/src/dotnetCampus.SourceYard/Assets/Target/build/$(PackageId).props @@ -12,4 +12,7 @@ True + + $(SourceYardPackageReference);#(PackageId) + \ No newline at end of file diff --git a/src/dotnetCampus.SourceYard/PackFlow/NuspecFileGenerator.cs b/src/dotnetCampus.SourceYard/PackFlow/NuspecFileGenerator.cs index 2a1c5cf..165aa07 100644 --- a/src/dotnetCampus.SourceYard/PackFlow/NuspecFileGenerator.cs +++ b/src/dotnetCampus.SourceYard/PackFlow/NuspecFileGenerator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -37,19 +38,19 @@ private void Write(NuspecPackage nuspecPackage, string fileName) var ns = new XmlSerializerNamespaces(); ns.Add("", ""); -//#if DEBUG + //#if DEBUG -// var str = new StringBuilder(); -// using (var xmlWriter = XmlWriter.Create(str)) -// { -// var xmlSerializer = new XmlSerializer(typeof(NuspecPackage)); -// xmlSerializer.Serialize(xmlWriter, nuspecPackage, ns); -// } + // var str = new StringBuilder(); + // using (var xmlWriter = XmlWriter.Create(str)) + // { + // var xmlSerializer = new XmlSerializer(typeof(NuspecPackage)); + // xmlSerializer.Serialize(xmlWriter, nuspecPackage, ns); + // } -// var rawceeyopereSuwhisa = str.ToString(); + // var rawceeyopereSuwhisa = str.ToString(); -// rawceeyopereSuwhisa = rawceeyopereSuwhisa; -//#endif + // rawceeyopereSuwhisa = rawceeyopereSuwhisa; + //#endif using (var stream = file.OpenWrite()) { @@ -88,18 +89,20 @@ private NuspecPackage GetNuspec(IPackingContext context) PackageLicenseUrl = buildProps.PackageLicenseUrl, PackageTags = buildProps.PackageTags, PackageReleaseNotes = buildProps.PackageReleaseNotes, - Dependencies = GetDependencies(context.PackageReferenceVersion), + Dependencies = GetDependencies(context.PackageReferenceVersion, buildProps.SourceYardPackageReferenceList), Repository = repository } }; } - private List GetDependencies(string contextPackageVersion) + private List GetDependencies(string contextPackageVersion, + List sourceYardPackageReferenceList) { - return ParserPackageVersion(contextPackageVersion); + return ParserPackageVersion(contextPackageVersion, sourceYardPackageReferenceList); } - private List ParserPackageVersion(string packageVersionFile) + private List ParserPackageVersion(string packageVersionFile, + List sourceYardPackageReferenceList) { var nuspecDependencyList = new List(); var packageVersionRegex = new Regex(@"Name='(\S+)' Version='([\S|\-]+)' PrivateAssets='(\S*)'"); @@ -117,7 +120,14 @@ private List ParserPackageVersion(string packageVersionFile) // 在源代码包如果项目引用的是 private asset 的库,那么就不应该添加引用 // 因为源代码是没有框架的依赖,对 sdk 带的库也不添加 - if (!privateAssets.Contains("all") + + var isPrivateAssetsAll = privateAssets.Contains("all"); + + // 解决 https://github.com/dotnet-campus/SourceYard/issues/60 + // 即使有某个包标记了使用 private asset 是 All 的,但是这个包是一个源代码包,那么打包的时候就需要添加他的引用依赖 + var includeInSourceYardPackageReference = sourceYardPackageReferenceList.Any(temp => temp.Equals(name, StringComparison.OrdinalIgnoreCase)); + + if ((!isPrivateAssetsAll || includeInSourceYardPackageReference) && !SDKNuget.Contains(name)) { nuspecDependencyList.Add(new NuspecDependency() diff --git a/src/dotnetCampus.SourceYard/Utils/BuildProps.cs b/src/dotnetCampus.SourceYard/Utils/BuildProps.cs index 55f65f3..7a17a84 100644 --- a/src/dotnetCampus.SourceYard/Utils/BuildProps.cs +++ b/src/dotnetCampus.SourceYard/Utils/BuildProps.cs @@ -138,6 +138,17 @@ public void SetSourcePackingDirectory(string packingDirectory) RepositoryUrl = appConfigurator.Default.GetValue("RepositoryUrl").Trim(); } + + var sourceYardPackageReferenceFile = Path.Combine(packingDirectory, "SourceYardPackageReferenceFile.txt"); + + List sourceYardPackageReferenceList = File.ReadAllLines(sourceYardPackageReferenceFile).Where(temp=>!string.IsNullOrEmpty(temp)).ToList(); + SourceYardPackageReferenceList = sourceYardPackageReferenceList; } + + /// + /// 安装的源代码包列表 + /// + /// 用于解决 https://github.com/dotnet-campus/SourceYard/issues/60 + public List SourceYardPackageReferenceList { get; private set; } } } \ No newline at end of file