简体   繁体   中英

using relative path on .nuget packages folder in .csproj file

How to use relative path on.nuget packages folder in.csproj file. I've.txt content files and it is copied to my bin directory if I make a build only if I set the property to copy always. By doing that I see a full hardcoded path value (c:\users\usr1234.nuget\packages\packagename\contentfiles\any\newfile.txt) in my.csproj file how to set the relative path in my.csproj file or is there any work around for this?

thanks in advance

In my case I had to remove some content files from my solution and the output directory. I did it by including the following in my .csproj file:

<ItemGroup>
  <None Remove="$(UserProfile)\.nuget\packages\your.package\*\contentFiles\any\somefile.txt" />
</ItemGroup>
  • $(UserProfile) corresponds to C:\\users\YourUsername
  • \*\ is used to be able to exclude files from differnet versions of your nuget package so you don't need to update this line when you update your nuget package to a new version

Also I'm not sure this will work outside Windows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM