Click Once 和 .NET Standard 兼容性问题

Click Once 和 .NET Standard 兼容性问题

最近使用Click Once打包使用.NET Standard库的WPF应用时,出现一些无法加载库文件的异常,例如:

Unable to initialize the application (Could not load file or assembly 'System.Runtime, Version=4.1.1.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a
' or one of its dependencies. The System cannot find the file specified.

这是一个Bug,https://github.com/dotnet/standard/issues/529

关于.NET Standard lib引用说明的文章:https://andrewlock.net/what-is-the-netstandard-library-metapackage/

 

微软给出了一个Workaround:

 

在***.csproj中添加如下代码,即可解决

<ItemGroup>
    <PublishFile Include="netfx.force.conflicts">
      <Visible>False</Visible>
      <PublishState>Exclude</PublishState>
      <IncludeHash>True</IncludeHash>
      <FileType>Assembly</FileType>
    </PublishFile>
  </ItemGroup>
  <Target Name="FixClickOnceDependencies" BeforeTargets="_DeploymentComputeClickOnceManifestInfo">
    <ItemGroup>
      <_noCopyRefs Include="@(ReferencePath)" Condition="'%(ReferencePath.Private)' == 'false'" />
      <_noCopyRefsByFileName Include="@(_noCopyRefs->'%(FileName)')">
        <OriginalItem>%(Identity)</OriginalItem>
      </_noCopyRefsByFileName>
      <_libByFileName Include="@(ReferenceCopyLocalPaths->'%(FileName)')">
        <OriginalItem>%(Identity)</OriginalItem>
      </_libByFileName>
      <_overlappingRefByFileName Include="@(_noCopyRefsByFileName)" Condition="'@(_noCopyRefsByFileName)' == '@(_libByFileName)' AND '%(Identity)' != ''" />
      <_overlappingLibByFileName Include="@(_libByFileName)" Condition="'@(_noCopyRefsByFileName)' == '@(_libByFileName)' AND '%(Identity)' != ''" />
      <_overlappingRef Include="@(_overlappingRefByFileName->'%(OriginalItem)')" />
      <_overlappingLib Include="@(_overlappingLibByFileName->'%(OriginalItem)')" />
    </ItemGroup>
    <ItemGroup Condition="'@(_overlappingRef)' != ''">
      <ReferencePath Remove="@(_overlappingRef)" />
      <ReferencePath Include="@(_overlappingLib)">
        <Private>True</Private>
      </ReferencePath>
    </ItemGroup>
  </Target>

 

转载于:https://www.cnblogs.com/devin_zhou/p/9278858.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值