简体   繁体   English

在.csproj 文件中使用.nuget 包文件夹中的相对路径

[英]using relative path on .nuget packages folder in .csproj file

How to use relative path on.nuget packages folder in.csproj file.如何在.csproj 文件中使用.nuget 包文件夹上的相对路径。 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.我有.txt 内容文件,如果我只在我将属性设置为始终复制时进行构建,它就会被复制到我的 bin 目录中。 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?通过这样做,我在 my.csproj 文件中看到了一个完整的硬编码路径值 (c:\users\usr1234.nuget\packages\packagename\contentfiles\any\newfile.txt) 如何在 my.csproj 文件中设置相对路径或者是有什么解决方法吗?

thanks in advance提前致谢

In my case I had to remove some content files from my solution and the output directory.就我而言,我必须从我的解决方案和 output 目录中删除一些内容文件。 I did it by including the following in my .csproj file:我通过在我的.csproj文件中包含以下内容来做到这一点:

<ItemGroup>
  <None Remove="$(UserProfile)\.nuget\packages\your.package\*\contentFiles\any\somefile.txt" />
</ItemGroup>
  • $(UserProfile) corresponds to C:\\users\YourUsername $(UserProfile)对应于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 \*\ 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另外我不确定这是否适用于 Windows

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 阻止 Nuget 将相对路径添加到 .csproj 文件 - Stop Nuget from adding the relative path to the .csproj file 移动文件夹 - csproj 和 Nuget - Move Folder - csproj and Nuget 如何从复制恢复或安装 Nuget 包然后粘贴到 *.csproj 文件? - How to restore or install Nuget packages from copy then paste to *.csproj file? 使用Nuget.css从csproj读取Nuget软件包 - Read Nuget Packages from csproj with Nuget.Packages NuGet、Packages.config、.csproj 和参考 - NuGet, Packages.config, .csproj and references 如何使用 MSBuild NuGet 将 .csproj 文件加载到 .NET Core 3.0 - How to Load .csproj file into .NET Core 3.0 using MSBuild NuGet 在构建 NuGet 包时,VS 将 csproj 文件中的元素伪装成<deterministic>和<embeduntrackedsources>不存在</embeduntrackedsources></deterministic> - When building NuGet packages, VS pretends elements in the csproj file like <Deterministic> and <EmbedUntrackedSources> don't exist 把$(SolutionDir)\ p​​ackages \放在.csproj文件而不是.. \ packages \ - put $(SolutionDir)\packages\ in .csproj file instead of ..\packages\ 从文件的根文件夹获取相对路径 - get relative path from root folder for a file Nuget 不还原解决方案的包,但在为 .csproj 执行时有效 - Nuget doesn't restore packages for solution, but works when executed for .csproj
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM