Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weave assemblies only if they do not already exist #1

Open
BlinD-HuNTeR opened this issue Apr 6, 2022 · 0 comments
Open

Weave assemblies only if they do not already exist #1

BlinD-HuNTeR opened this issue Apr 6, 2022 · 0 comments

Comments

@BlinD-HuNTeR
Copy link

BlinD-HuNTeR commented Apr 6, 2022

Currently the MTP_AssembliesWeaverTask task is invoked every time the project is compiled, which not only imposes an overhead but also breaks incremental compilation.

By adding the following target to my project, I was able to make this task be invoked only for assemblies that don't already exist:

    <Target
        Name="MTP_ExistingReferences"
        Condition="$(IgnoreAccessChecks) == 'true'"
        DependsOnTargets="MTP_GetSourceReferences;MTP_GetTargetReferences;MTP_DisableAccessChecks_Runtime"
        BeforeTargets="MTP_DisableAccessChecks">

        <ItemGroup>
            <MTP_ExistingSourceReferences Include="@(MTP_SourceReferences)" Condition="Exists('$(BaseIntermediateOutputPath)MakeTypesPublic\Assemblies\%(Filename)%(Extension)')" />
            <MTP_ExistingTargetReferences Include="@(MTP_TargetReferences->Exists())" />
            <MTP_SourceReferences Remove="@(MTP_ExistingSourceReferences)" />
            <MTP_TargetReferences Remove="@(MTP_ExistingTargetReferences)" />
            <ReferencePath Remove="@(MTP_ExistingSourceReferences)" />
            <ReferencePath Include="@(MTP_ExistingTargetReferences)" />
        </ItemGroup>
    </Target>

With this target in place, assemblies don't get weaved on every compilation. Everything works fine, and incremental compilation starts working again.

Also you can even enable weaving at design-time with no drawbacks. You can probably even remove the IgnoreAccessChecks property and make this the defaut behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant