我可以将此旧的csproj迁移到VS2017 csproj吗?

时间:2018-12-06 10:15:45

标签: c# visual-studio visual-studio-2015 nuget csproj

我想简化PCL csproj,但似乎找不到合适的TargetFrameworks。.

这是我的旧csproj:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{D035A2E6-EF3E-4F50-B6D7-396F83FE313F}</ProjectGuid>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <RootNamespace>PCL.Acme</RootNamespace>
    <AssemblyName>PCL.Acme</AssemblyName>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
  </PropertyGroup>

当前nuget的框架文件夹格式为portable46-net451%2Bwin81%2Bwpa81。 我无法定位netstandard1.2,因为我依赖另一个PCL ...

感谢您的帮助。

更新

这种csproj格式可以引用我的旧PCL nuget包。 现在,我可以开始迁移PCL.Acme.Another.Library项目了。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.2</TargetFrameworks>
    <PackageId>PCL.Acme</PackageId>
    <Authors>Acme</Authors>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <PackageTargetFallback>
      $(PackageTargetFallback);portable46-net451+win81+wpa81
    </PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="PCL.Acme.Another.Library" Version="1.0.0" />
  </ItemGroup>
</Project>

1 个答案:

答案 0 :(得分:2)

我会用新格式重新创建csproj(重新开始),这要容易得多。这篇博客文章确实很有帮助https://natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/

编辑:所有受支持的目标框架https://docs.microsoft.com/en-us/dotnet/standard/frameworks

Edit2:

<PackageTargetFallback>
    $(PackageTargetFallback);portable-net45+win8+wpa81+wp8
</PackageTargetFallback>

也可能会有所帮助。更多信息,请点击https://docs.microsoft.com/en-us/dotnet/core/tools/csproj

如果链接断开

类库

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>
</Project>

控制台应用程序

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>
</Project>

测试项目

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net46</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="xunit" Version="2.2.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>
</Project>