<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
In my \PublishProfiles\FolderProfile.pubxml, it works only for the project you publish, not for references. I tried to do as @ducalai suggested - added publish parameters /p:DebugType=None /p:DebugSymbols=false
and it worked for references too. BTW the same thing with -p:Configuration=Release
When I try this and I but this two lines in my .pubxml file I get this error:
https://stackoverflow.com/questions/77071059/the-debug-type-specified-in-the-dependency-context-could-be-parsed-asp-core-er/77071060#77071060
Triage: @richaverma1 can you have your team set up a repro of this and provide a binlog? It should be a project that depends on another project and sets -p:DebugType=None -p:DebugSymbols=false during the publish but the dependent are still being picked up.
It's not about debug symbols but other files that might be included in the project but we don't want to deploy. appsettings.json
is a main example of that. web.config
for web apis.
The point is we can do that with .NET Framework projects but not with .NET ones because publication using .pubxml files doesn't support it.
So the options provided correctly remove the pdbs but there is a desire for a solution for other files as well? We'll sync in triage next week on this. From our vendor testing, setting those properties in individual project files affects only those projects but setting it on the command line as suggested, does affect all projects which matches AGlezB commented.
So the options provided correctly remove the pdbs but there is a desire for a solution for other files as well? We'll sync in triage next week on this. From our vendor testing, setting those properties in individual project files affects only those projects but setting it on the command line as suggested, does affect all projects which matches AGlezB commented.
To be clear the main issue for me is that .pubxml
has a syntax to specify files to exclude but in on only works for certain files. Here is an extract from a publish profile from one of our Web Api projects:
<!-- Esto es para que no incluya archivos innecesarios al publicar -->
<ItemGroup>
<Content Update="appsettings*.json" CopyToPublishDirectory="Never" />
Esto no funciona todavía con .NET Core
https://github.com/dotnet/sdk/issues/16975
<Content Update="*.xml" CopyToPublishDirectory="Never" />
<Content Update="*.pdb" CopyToPublishDirectory="Never" />
<Content Update="PrecisionApi.xml" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
The translation for the comments is:
<!-- To exclude unnecesary files on publish -->
<ItemGroup>
<!-- This isn't working on .NET Core yet -->
</ItemGroup>
The meaning of the settings is: we don't want any appsettings*.json
or .xml
(dll documentation) or .pdb
files but we do want the PrecisionApi.xml
file because that one populates the Swagger UI documentation.
Of those the only one that works is the appsettings*.json
one because the file are already included in the project. The other files are generated by the build process and the publish process doesn't recognize them which is why those are commented out and I'm keeping an eye on this issue.
Ideally all four would work, which is to say I'd like to be able to write the rules in the .pubxml
, commit the file to source control and forget about it. Command line is convenient but it's secondary to making the publish profile work.
We investigated a bit and think you will need a custom target to accomplish this in a consistent manner. The reason for this is that your pubxml file is being read during project evaluation, but many of the items you want to customize are only available during build execution - they are created during the build. By definition, you must use targets to interact with these kinds of items.
I think a good place to start investigating would be the DefaultCopyToPublishDirectoryMetadata
target - this target in the SDK is responsible for defining how the Content/etc items are marked for copying to publish directories. If you create a target that has BeforeTargets="DefaultCopyToPublishDirectoryMetadata"
then you should be able to detect any of the PDBs and other files you want to remove and set their metadata to not be copied.
You can investigate your builds in detail using the MSBuild Structured Log Viewer tool.