Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

NuGet to copy files into the project directory

$
0
0

I've created a .nuspec file which packages a bunch of .proto files for sharing between projects. This is great. Unfortunately, for the .proto files to be built, they need to be actually copied over to the project directory, not just referenced. Note that this is a .NET Core project.

Right now my definition creates a package that, when used, references the files in the project, but these files still reside in the original .Nuget folder, and that's not really what I need.

Here's the .nuspec definition that I've got right now:

<?xml version="1.0"?><package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"><metadata><id>GRPCProtoFiles</id><version>1.0.0</version><authors>Author</authors><requireLicenseAcceptance>false</requireLicenseAcceptance><description>.proto files NuGet package.</description><dependencies><dependency id="Google.Protobuf" version="3.14.0"/><dependency id="Grpc" version="2.35.0"/></dependencies><contentFiles><files include="any/any/Protos/**/*.proto" buildAction="None" copyToOutput="false" /></contentFiles></metadata><files><file src="**\*.proto" target="contentFiles\any\any\Protos" exclude="google\**" /></files></package>

I know that "build action" is currently set to "none", but I can get that fixed once the files land in the correct folder upon package installation. As is, if I try to set the build action for the proto files to the correct one (which is Protobuf Compiler) then I get an error, because the files aren't where they're supposed to be.

What am I doing wrong?

EDIT:

OK, I've read up a bit on what might be happening and why. Specifically this answer gave me a lot of insight. However I'm left wondering how I can actually do what I need to do. Right now it seems that what I want to do is impossible with NuGet and I'm using the wrong tool for the job. But besides this one limitation NuGet seems ideal - it's able to pick just the .proto files from the source project and just publish that rather then pre-built libraries for various target systems.

I could, possibly, add a pre-build action to copy the files to the project dir, but I've no idea how to reference the source NuGet package folder (especially if the version changes). Any idea if this problem even has a solution?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>