【问题标题】:Future of cs project file and nuspec filecs项目文件和nuspec文件的未来
【发布时间】:2017-04-06 06:21:10
【问题描述】:

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

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

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

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

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

找到相关资源:

【问题讨论】:

    标签: .net asp.net-core asp.net-core-2.0


    【解决方案1】:

    我今天发现安装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 prop文件。 dotnet 将在内部将这些标记转换回.nuspec 文件和 AssemblyVersionInfo 文件,然后使用这些文件构建它。

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

    【讨论】:

      猜你喜欢
      • 2013-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多