Could not load file or assembly SmartAssembly.MSBuild.Tasks

Hi there,

We are trying to automate obfuscation with MSBuild integration, we are able to obfuscate manually via GUI. When adding additional code to a csproj file we receive an error just as below:

error MSB4062: Culture=neutral, PublicKeyToken=7f465a1c156d4d57. Could not load file or assembly 'SmartAssembly.MSBuild.Tasks, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57'.

We've followed these instructions accordingly: https://documentation.red-gate.com/sa7/building-your-assembly/using-smartassembly-with-msbuild?_ga=2.260650253.1219834847.1565511253-1957869546.1565267750

note: we are testing the trial version
Tagged:

Answers

  • Hi @matilote,

    Can you please confirm that you have SmartAssembly 7 installed on the machine where the build is occurring?  Please also let me know the specific build of SmartAssembly 7 it is.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • matilotematilote Posts: 2 New member
    Hi Alex,

    Yes, SA 7 is installed on the machine.

    This is how does our csproj file look like.
    I am not able to share saproj, but it works to build an obfuscated file manually, so the error must lay somewhere in the csproj file below.

    <Project Sdk="Microsoft.NET.Sdk">

        <PropertyGroup>
          <TargetFramework>netcoreapp2.2</TargetFramework>
          <SmartAssemblyProjectFile>$(ProjectDir)$(AssemblyName).saproj</SmartAssemblyProjectFile>
          <_SATaskAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">SmartAssembly.MSBuild.Tasks_NetStandard, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57</_SATaskAssembly>
          <_SATaskAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">SmartAssembly.MSBuild.Tasks, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57</_SATaskAssembly>
        </PropertyGroup>

        <ItemGroup>
          <ProjectReference Include="..\xyz\src\XYZ\XYZ.Core\XYZ.Core.csproj" />
          <ProjectReference Include="..\xyz\src\XYZ\XYZ.Network\XYZ.Network.csproj" />
        </ItemGroup>
     
        <UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="$(_SATaskAssembly)" />
        <Target Name="BuildWithSmartAssembly" AfterTargets="Build" Condition=" '$(Configuration)' == 'Release' ">
          <SmartAssembly.MSBuild.Tasks.Build ProjectFile="$(SmartAssemblyProjectFile)" />
        </Target>
     
    </Project>
  • Hi @matilote,

    I've just done a quick test with a console application targetting .Net Core 2.2 and it has worked for me:


    The only difference that I can see is that you have the <ItemGroup> between the two parts of the SmartAssembly task... if you rearrange this so that it is the entire SmartAssembly task portion pasted in as the last part of the csproj (before the end </Project> tag) does it behave any differently?

    Also what specific version of SA7 do you have installed?  I'm using 7.0.7 in the image and I've updated to 7.0.8 and it works there as well.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.