如何在Nuget中排除内容目录

发布于 2025-02-05 19:19:15 字数 1356 浏览 1 评论 0原文

我正在尝试使用我的CSPROJ和MSBUILD构建Nuget。 Nuget软件包成功创建了。但是我看到内容和contentFiles文件夹,其中包含我的 20 .proto文件。 当有人下载​​我的nuget时,他们也会得到我的原始文件。但是我不想给那些文件。如何避免使用.proto文件。

我没有.nuspec文件。

我的csproj看起来像这样:

<PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
        
        <PackageId>BlahBlah</PackageId>
        <Title>BlahBlah</Title>
        <Version>1.0.0</Version>
        <Authors>Test</Authors>
        <Company>Test</Company>
        <PackageTags>Test nuget</PackageTags>
        
        <DebugType>portable</DebugType>
        <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>        
       
        <PackageOutputPath>Blah</PackageOutputPath>
</PropertyGroup>

<Target Name="Test1" AfterTargets="Pack" Condition="$(PackOnBuild) == 'true'">
        <ItemGroup>
            <PackageFile Include="$(TestVersion).nupkg" />
        </ItemGroup>
        <Copy SourceFiles="@(src)" DestinationFolder="$(dst)" />
</Target>

I am trying to build nuget with my csproj and MSBuild.
Nuget package gets created successfully. But I see content and contentFiles folder where it has my 20 .proto files.
And when someone downloads my nuget, they also get my proto files. But I don't want to give those files. How Can I avoid having .proto files.

I don't have .nuspec file.

My csproj looks like this :

<PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
        
        <PackageId>BlahBlah</PackageId>
        <Title>BlahBlah</Title>
        <Version>1.0.0</Version>
        <Authors>Test</Authors>
        <Company>Test</Company>
        <PackageTags>Test nuget</PackageTags>
        
        <DebugType>portable</DebugType>
        <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>        
       
        <PackageOutputPath>Blah</PackageOutputPath>
</PropertyGroup>

<Target Name="Test1" AfterTargets="Pack" Condition="$(PackOnBuild) == 'true'">
        <ItemGroup>
            <PackageFile Include="$(TestVersion).nupkg" />
        </ItemGroup>
        <Copy SourceFiles="@(src)" DestinationFolder="$(dst)" />
</Target>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2025-02-12 19:19:15

根据,您可以设置&lt; pack&gt; false&lt;/pack&gt;从Nuget软件包中排除文件。

由于我不知道proto文件被视为contentnone,它应该是

<PropertyGroup>
    <Content Include="*.proto">
        <Pack>false</Pack>
    </Content>
</PropertyGroup>

<PropertyGroup>
    <None Include="*.proto">
        <Pack>false</Pack>
    </Content>
</PropertyGroup>

csproj 代码>。

According to the Microsoft docs, you can set <Pack>false</Pack> to exclude files from the NuGet package.

Since I don't know whether proto files are treated as Content or None, it should be either

<PropertyGroup>
    <Content Include="*.proto">
        <Pack>false</Pack>
    </Content>
</PropertyGroup>

or

<PropertyGroup>
    <None Include="*.proto">
        <Pack>false</Pack>
    </Content>
</PropertyGroup>

within the csproj.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文