msbuild /t:Pack seems to copy assemblies from project references instead of output folder. · Issue #227 · novotnyllc/MSBuildSdkExtras · GitHub
Skip to content

msbuild /t:Pack seems to copy assemblies from project references instead of output folder. #227

Open

Description

@softlion

Hey again ! 😀

I have a msbuild Target which calls the obfuscar tool on the assemblies output of a build (in AfterBuild). I can't get it to work fully when packing a SDK Extra project.

When using /t:Pack, the nuget package contains an obfuscated assembly only for the SDK extra project, and a non obfuscated assembly for the library project that the SDK project is referencing.

The most strange thing is that all assemblies in each output folder of the SDK Extra project are correctly obfuscated.

It seems that the packing process ignores the output folder for referenced projects. I know that referenced projects are normally ignored by the packing target, which adds a nuget dependency instead (each project should have its nuget). I used this "trick" to get it into the main package instead:

  <PropertyGroup>
 <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
  </PropertyGroup>
  <Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
    <ItemGroup>
      <BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
    </ItemGroup>
    <Message Text="BuildOutputInPackage: @(BuildOutputInPackage)" />
  </Target>

An excerp of the obfuscar target:

<Target Name="Obfuscate" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
    <ItemGroup>
       <AssembliesToObfuscate Include="$(TargetDir)\*.dll" />
    </ItemGroup>
     ...
    <Copy DestinationFolder="$(TargetDir)" SourceFiles="@(ObfuscarFiles)" />
  </Target>

Activity

  1. softlion commented on May 22, 2020

    @softlion
    Author

    Ok i found the .nuspec file that the packing process is generating. It uses the output path of the referenced project for its assembly instead of the output path of the SDK Extra project (which contains the same assembly but obfuscated).

    The problem is that i can't obfuscate the output of the referenced project alone. All assemblies need to be obfuscated at the same time.

    Do you know an extension point where i can fix the content of this nuspec file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions