我们已将应用程序(由 20 多个项目和 5 个可执行文件组成)移至 asp net core (1.1) 和 project.json (.xproj)。
我们已经全部运行起来,但现在我们正在将某些项目作为包移动到我们的内部 nuget feed。我们可以使用project.json来创建nuget包,但我们仍然可以使用nuspec文件来创建包(尽管这些占位符不再自动填充)。
由于 Microsoft 宣布他们将放弃 project.json 并返回到旧的 xml 项目结构,我想知道 nuspec 支持会发生什么?
我一直在研究这个问题,但找不到任何相关信息。
有谁知道这个项目文件的 future 将如何包含 nuspec 支持或者 nuspec 文件仍然是必要的吗?
找到相关资源:
最佳答案
今天我发现安装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>
它确实包含 nuget 包引用,这使得packages.config 变得不必要。它可能仍然需要像以前一样的 nuspec 文件。
我发现了什么
是基于项目文件上添加的这些 Xml 标记,并且默认 dotnet 添加了 msbuild prop 文件。 dotnet 会在 onbuild 内部将这些标记转换回 .nuspec
文件和 AssemblyVersionInfo 文件,然后使用这些文件进行构建。
它 super hacky,但我想它是有效的。 (至少在 NetStandard2.0 发布之前它是这样工作的,但我认为它仍然可以工作)
关于.net - cs 项目文件和 nuspec 文件的 future ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40744169/