2

我们已将我们的应用程序(由 20+- 项目和 5 个可执行文件组成)移至 asp net core (1.1) 和 project.json (.xproj)。

我们让它全部运行,但现在我们正在将某些项目作为包移动到我们的内部 nuget 提要。我们可以使用 project.json 来创建 nuget 包,但我们仍然可以使用 nuspec 文件来创建包(尽管这些占位符不再自动填充)。

自从微软宣布他们将放弃 project.json 并回到他们旧的 xml 项目结构,我想知道 nuspec 支持会发生什么?

我一直在研究这个,但找不到任何关于这个的信息。

有谁知道这个项目文件的未来将如何包含 nuspec 支持,或者仍然需要 nuspec 文件?

找到相关资源:

4

1 回答 1

2

我今天发现安装 vs2017 时安装了预览版(preview3),你也可以在这里找到它:https ://github.com/dotnet/core/blob/master/release-notes/preview3-download.md

这个新的 sdk 包含一个dotnet migrate将 project.json 和 xproj 文件转换回 .csproj 文件的功能。

新的项目文件将如下所示:

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <AssemblyName>MyProject</AssemblyName>
    <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
    <EmbeddedResource Include="compiler\resources\**\*" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\OtherProject.csproj" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161104-2</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="NETStandard.Library">
      <Version>1.6.1</Version>
    </PackageReference>
    <PackageReference Include="ServiceStack.Common.Core">
      <Version>1.0.*</Version>
    </PackageReference>
    <PackageReference Include="ServiceStack.Text.Core">
      <Version>1.0.*</Version>
    </PackageReference>
    <PackageReference Include="System.Linq.Queryable">
      <Version>4.3.0</Version>
    </PackageReference>
  </ItemGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
  </PropertyGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

它确实包含使 packages.config 不必要的 nuget 包引用。它可能仍然需要像以前一样的 nuspec 文件。

我在背后发现了什么

是基于这些在项目文件中添加的 Xml 标记,并且默认 dotnet 添加了 msbuild 属性文件。dotnet 将在内部将这些标记转换回.nuspec文件和 AssemblyVersionInfo 文件,然后使用这些文件构建它。

它超级hacky,但我想它有效。(至少在 NetStandard2.0 发布之前它是这样工作的,但我认为它仍然可以正常工作)

于 2016-11-24T10:39:35.243 回答