我想在Visual Studio 2017 RC中打包.Net Framework库.在带有project.json构建系统的VS 2015中,我能够通过将自定义目标文件导入.xproj文件来实现此目的.此自定义目标文件负责创建nuspec文件(如果该文件不存在),然后运行nuget pack,将生成的包复制到本地Feed位置等.
我是否需要在2017年做类似的事情(还没有认真努力)或者我能以某种方式在我的.csproj文件中启用包目标吗?
此处的文档仅显示从命令行运行pack目标.
编辑: 我正在尝试从夜间构建中引用Nuget 4.0 exe的以下自定义目标...
<Target Name="PackNugets" AfterTargets="Build">
<PropertyGroup>
<NugetV4Path>$([System.IO.Path]::GetFullPath('path to nuget.exe'))</NugetV4Path>
</PropertyGroup>
<Exec Command=""$(NugetV4Path)\nuget.exe" pack "$(MSBuildProjectDirectory)\$(PackageId).csproj" -Symbols -OutputDirectory bin -Properties Configuration=Release"/>
</Target>
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'NuGet.Frameworks.NuGetFramework'.
at NuGet.ProjectManagement.NuGetProject.GetMetadata[T](String key)
at NuGet.ProjectManagement.PackagesConfigNuGetProject..ctor(String folderPath, Dictionary`2 metadata)
at CallSite.Target(Closure , CallSite , Type , Object , Dictionary`2 )
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at NuGet.CommandLine.ProjectFactory.AddDependencies(Dictionary`2 packagesAndDependencies) …Run Code Online (Sandbox Code Playgroud)