請問我有問題。抱歉,如果問題標題未被很好地識別,我無法在我的聲譽期間上傳完整影像。
編輯:我可能需要類似的東西
<ProjectReference>應該加載并且應該在我的解決方案中可見。問題簡短描述:
- 我在解決方案 A 中有主要專案。(必須對其他人公開 GIT)
- 我在解決方案 B 中有類別庫(可能在 2 個主要專案中使用)(必須是 GIT 私人倉庫僅供我使用)
- 我需要的類別庫源只對我可見,其他人不可見。他們只看到包或 DLL。
- 主要專案是公共 Git 倉庫,而類別庫是私有 Git 倉庫。
- 就我而言,我需要設定 2 種型別的 MSBuild 配置。(除錯/)和(Nuget/)
- 其他人只允許使用私有的nuget包,他們不能除錯類別庫。
- 我只需要我使用 (
Debug/<ProjectReference>) -> 所以我可以直接更改類別庫并為其他人構建 Nuget 包,而無需包含 PDB 檔案等。
我嘗試做什么?我閱讀了哪些主題?
- 我關注我關注的主題:
我需要改變什么嗎?
uj5u.com熱心網友回復:
目前還沒有官方的解決方案。
因此,如果有人需要我收集的方法,我會修改一些標簽以防止 PackageName 與 ProjectName 沖突,這是最終解決方案,原件復制自https://github.com/dotnet/sdk/issues/1151#issuecomment-459275750 非常感謝腳本作者:
這是它的增強版本:
<PropertyGroup> <ReplacePackageReferences Condition="'$(ReplacePackageReferences)' == ''">true</ReplacePackageReferences> <ReplaceProjectReferences Condition="'$(ReplaceProjectReferences)' == ''">true</ReplaceProjectReferences> </PropertyGroup> <Choose> <When Condition="'$(SolutionPath)' != '' AND '$(SolutionPath)' != '*undefined*' AND Exists('$(SolutionPath)')"> <PropertyGroup> <SolutionFileContent>$([System.IO.File]::ReadAllText($(SolutionPath)))</SolutionFileContent> <SmartSolutionDir>$([System.IO.Path]::GetDirectoryName( $(SolutionPath) ))</SmartSolutionDir> <RegexPattern>(?<="[PackageName]", ")(.*)(?=", ")</RegexPattern> <HasSolution>true</HasSolution> </PropertyGroup> </When> <Otherwise> <PropertyGroup> <HasSolution>false</HasSolution> </PropertyGroup> </Otherwise> </Choose> <Choose> <When Condition="$(ReplacePackageReferences) AND $(HasSolution)"> <ItemGroup> <!-- Keep the identity of the packagereference --> <SmartPackageReference Include="@(PackageReference)"> <InProject>false</InProject> <PackageName>%(Identity)</PackageName> <InSolution>$(SolutionFileContent.Contains('\%(Identity).csproj'))</InSolution> </SmartPackageReference> <!-- Filter them by mapping them to another itemGroup using the WithMetadataValue item function --> <PackageInSolution Include="@(SmartPackageReference -> WithMetadataValue('InSolution', True) )"> <Pattern>$(RegexPattern.Replace('[PackageName]','%(PackageName)') )</Pattern> <SmartPath>$([System.Text.RegularExpressions.Regex]::Match( '$(SolutionFileContent)', '%(Pattern)' ))</SmartPath> <ProjName>'%(PackageName)'</ProjName> </PackageInSolution> <ProjectReference Include="@(PackageInSolution -> '$(SmartSolutionDir)\%(SmartPath)' )"> <Name>@(PackageInSolution -> %(ProjName))</Name> </ProjectReference> <!-- Remove the package references that are now referenced as projects --> <PackageReference Remove="@(PackageInSolution -> '%(PackageName)' )" /> </ItemGroup> </When> <When Condition="$(ReplaceProjectReferences) AND '$(_RestoreSolutionFileUsed)' == ''"> <ItemGroup> <!-- Keep the identity of the project reference (relative path), determine the project name and whether the project is contained in the current solution --> <SmartProjectReference Include="@(ProjectReference)"> <OriginalIdentity>%(Identity)</OriginalIdentity> <ProjectName>$([System.IO.Path]::GetFileNameWithoutExtension( $([System.IO.Path]::GetFullPath( '%(OriginalIdentity)' )) ))</ProjectName> <InSolution>$(SolutionFileContent.Contains('\%(ProjectName).csproj'))</InSolution> </SmartProjectReference> <!-- Filter them by mapping them to another itemGroup using the WithMetadataValue item function --> <ProjectNotInSolution Include="@(SmartProjectReference -> WithMetadataValue('InSolution', False) )"> </ProjectNotInSolution> <!--Reference the latest version of the package (why not * ? > see https://github.com/NuGet/Home/issues/7328--> <PackageReference Include="@(ProjectNotInSolution -> '%(ProjectName)' )" Version="*" /> <!-- Remove the project references that are now referenced as packages --> <ProjectReference Remove="@(ProjectNotInSolution -> '%(OriginalIdentity)' )" /> </ItemGroup> </When> </Choose>請注意,如果您需要自動更新 nuget 包,則必須在上面提供的腳本上方指定包:
<ItemGroup> <PackageReferen``ce Include="FooClassLibrary" Version="*"/> </ItemGroup>隨意修改或編輯上面的腳本或編輯答案。如果您找到更好的答案,請發布它(例如,您為此創建了新的擴展名或其他內容)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/429860.html標籤:C# 视觉工作室 dll nuget 视觉工作室 2022
上一篇:無法使用ProcessStartInfo引數將“”傳遞給powershell,C#
下一篇:無法將自定義ActiveX控制元件添加到.NETWinForms應用程式。.NETFrameworkWinForms應用程式運行良好
