user19011893
user19011893

Reputation: 23

How to Exclude Content directory in Nuget

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>

Upvotes: 0

Views: 1166

Answers (1)

mu88
mu88

Reputation: 5374

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.

Upvotes: 3

Related Questions