user2916547
user2916547

Reputation: 2033

Nuspec file target absolute path

I am writing a .nuspec file and a file must be copied to a specific absolute path when installing the package.

The snippet looks like this:

<files>
    <file src="myFolder\myFile.txt" target="C:\SomeFolder\myFolder" />
</files>

When I run nuget pack, I get the following error (this is -Verbosity detailed):

Target path 'C:\SomeFolder\myFolder' contains invalid characters.

System.Exception: Target path 'C:\SomeFolder\myFolder' contains invalid characters. at NuGet.Packaging.Manifest.Validate(Manifest manifest) at NuGet.Packaging.Manifest.ReadFrom(Stream stream, Func2 propertyProvider, Boolean validateSchema) at NuGet.Packaging.PackageBuilder.ReadManifest(Stream stream, String basePath, Func2 propertyProvider) at NuGet.Packaging.PackageBuilder..ctor(String path, String basePath, Func`2 propertyProvider, Boolean includeEmptyDirectories, Boolean deterministic) at NuGet.Commands.PackCommandRunner.CreatePackageBuilderFromNuspec(String path) at NuGet.Commands.PackCommandRunner.BuildFromNuspec(String path) at NuGet.Commands.PackCommandRunner.BuildPackage() at NuGet.CommandLine.PackCommand.ExecuteCommand() at NuGet.CommandLine.Command.ExecuteCommandAsync() at NuGet.CommandLine.Command.Execute() at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

I suppose this is related to the using the absolute path but

1) this used to work a year ago (I don't recall the exact version of nuget I had back then)

2) how do I specify an absolute path?

I am using the latest version of nuget, which I downloaded this morning.

Upvotes: 1

Views: 1325

Answers (1)

user2916547
user2916547

Reputation: 2033

Turns out this is by design, as they consider a security concern to have a nuget package that changes things outside the scope of the project where it gets installed. As answered in Github: https://github.com/NuGet/Home/issues/9329 (also as Mihai Albert mentioned in the comment)

A workaround I ended up using is packaging using relative paths and installing the package in the desired location.

Upvotes: 1

Related Questions