我有一个多目标定位项目(netstandard2.0
和net461
)。
当我收集项目时,我得到了一个包。
如何限制版本? (= 1.0.6)
我试图这样做Version =“[1.0.6]”,但之后项目没有构建
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl></RepositoryUrl>
<Copyright>-</Copyright>
<Description>-</Description>
<Company>-</Company>
<Authors>-</Authors>
<PackageProjectUrl>-</PackageProjectUrl>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>OracleExtensions.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<Version>1.0.7</Version>
<AssemblyVersion>1.0.7.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\PRB.OracleExtensions.xml</DocumentationFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\PRB.OracleExtensions.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="licenses.licx" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="licenses.licx" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Devart.Data" Version="5.0.1926" />
<PackageReference Include="Devart.Data.Oracle" Version="9.5.502" />
<PackageReference Include="Devart.Data.Linq" Version="4.8.1471" />
<PackageReference Include="Devart.Data.Oracle.Linq" Version="4.8.1471" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.2" />
<ProjectReference Include="..\PRB.Extensions\PRB.Extensions.csproj">
<SpecificVersion>True</SpecificVersion>
</ProjectReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="Devart.Data, Version=5.0.1926.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<Private>True</Private>
<HintPath>C:\Program Files (x86)\Common Files\Devart\dotConnect\NET2\Devart.Data.dll</HintPath>
</Reference>
<Reference Include="Devart.Data.Linq, Version=4.8.1471.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<Private>True</Private>
<HintPath>C:\Program Files (x86)\Common Files\Devart\dotConnect\NET2\Devart.Data.Linq.dll</HintPath>
</Reference>
<Reference Include="Devart.Data.Oracle, Version=9.5.502.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<Private>True</Private>
<HintPath>C:\Program Files (x86)\Common Files\Devart\dotConnect\NET2\Devart.Data.Oracle.dll</HintPath>
</Reference>
<Reference Include="Devart.Data.Oracle.Linq, Version=4.8.1471.0, Culture=neutral, PublicKeyToken=09af7300eec23701, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
<Private>True</Private>
<HintPath>C:\Program Files (x86)\Common Files\Devart\dotConnect\NET2\Devart.Data.Oracle.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" Version="4.4.1" />
<Reference Include="System.ServiceModel" Version="4.0.0" />
<ProjectReference Include="..\PRB.WcfExtensions\PRB.WcfExtensions.csproj">
<SpecificVersion>True</SpecificVersion>
</ProjectReference>
<ProjectReference Include="..\PRB.Extensions\PRB.Extensions.csproj">
<SpecificVersion>True</SpecificVersion>
</ProjectReference>
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
</ItemGroup>
</Project>
答案 0 :(得分:1)
如何在构建包时限制版本?
这是关于限制ProjectReference
版本的已知问题。目前,Hibernate 不支持ProjectReference
,因此我们无法限制ProjectReference
的版本限制,就像我们在PackageReference
上所做的那样。
对于已知问题,请检查:semantic versioning。
作为解决方法,我们可以将ProjectReference
转换为PackageReference
,然后将Version="[1.0.6]"
转换为PackageReference
。
详细步骤:
1)为项目PRB.Extensions
和PRB.WcfExtensions
生成nuget包,获取包PRB.Extensions.1.0.6.nupkg
和PRB.WcfExtensions.1.0.0.nupkg
。
2)将这两个包设置为本地Feed,然后将它们安装到项目PRB.OracleExtensions
,然后您将获得以下代码:
<ItemGroup>
<PackageReference Include="PRB.Extensions" Version="1.0.6" />
</ItemGroup>
3)将版本限制设置为PackageReference
:
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="PRB.Extensions" Version="[1.0.6]" />
<PackageReference Include="PRB.WcfExtensions" Version="[1.0.0]" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="PRB.Extensions" Version="[1.0.6]" />
</ItemGroup>
注意:当您使用PackageReference
代替ProjectReference
时,应在将nuget包添加到项目ProjectReference
之前删除PRB.OracleExtensions