Reputation: 24525
I'm currently upgrading from the *.xproj
with project.json
format to the *.csproj
file formats, leveraging the newer Visual Studio 2017 tooling. Below is the version I'm on for both the IDE and the SDK / .NET Core CLI:
Microsoft Visual Studio Community 2017
Version 15.4.3
VisualStudio.15.Release/15.4.3+27004.2008
Microsoft .NET Framework
Version 4.7.02558
.NET Command Line Tools (2.0.2)
Product Information:
Version: 2.0.2
Commit SHA-1 hash: a04b4bf512
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.2\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
With that said, I'm curious how can I exclude wwwroot
from my NuGet package that is created without relying on a .nuspec
. Is this possible?
.csproj
Here is my .csproj
:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<!-- omitted for brevity -->
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\**\*;node_modules" />
<EmbeddedResource Include="Views\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>lib/net461/</PackagePath>
<Pack>true</Pack>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<!-- package references, omitted for brevity -->
</ItemGroup>
</Project>
Here is an image of the package contents:
Ideally, I want to content to resemble exclude the content
and contentFiles
bits and instead just be the lib
with the .exe
.
Upvotes: 4
Views: 1219
Reputation: 100581
You can modify the content items in the project file to set the Pack
metadata to false
for either just the wwwroot folder or for all content items:
<ItemGroup>
<!-- only exclude wwwroot items from package -->
<Content Update="wwwroot/**" Pack="false" />
<!-- Exclude all content from package (e.g. appsettings.json) -->
<Content Update="@(Content)" Pack="false" />
</ItemGroup>
Upvotes: 5