My question is similar to this and this .
I want to pack the .Net Framework library in Visual Studio 2017 RC. In VS 2015 with the project.json build system, I was able to accomplish this by importing a custom goals file into a .xproj file. This target file took care of creating the nuspec file if it does not exist, then run the nuget package, copy the resulting packages to a local folder, etc.
Do I need to do something like this in 2017 (have not taken any serious efforts yet), or can I somehow include the package target in my .csproj file?
The docs here show only to launch the package target from the command line.
EDIT: I'm trying to use the following custom target referencing a Nuget 4.0 exe from nightly collections ...
<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>
But I get the following error
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) at NuGet.CommandLine.ProjectFactory.ProcessDependencies(PackageBuilder builder) at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder) at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path) at NuGet.CommandLine.PackCommand.ExecuteCommand() at NuGet.CommandLine.Command.ExecuteCommandAsync() at NuGet.CommandLine.Command.Execute() at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
Something related to one of the properties in csproj? Does NugetFramework describe the value of TargetFramework ?
I am targeting net452 in my csproj, in case this helps.
EDIT: This exception is really related to nuget trying to parse TargetFramework , but it is not clear if it works on my csproj or on the dependency ...