msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Msbuild doesn't generate assemblyBinding if run multi-target (restore;build) at same command for first time

Open tangkhaiphuong opened this issue 2 years ago • 1 comments

Scenerio:

  • I created project call FooProgram is windows form with localization support and use new-style csproj. And I reference to System.Resources.Extensions and configure <GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
  • Then I create another program call ClientAppProgram reference to FooProgram.
  • Both 2 application configure with target framework is net472.

Issue Description

  • If I use Visual Studio build both 2 projects. Not problem. The assemblyBinding are generated and append to .exe.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Resources.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Then I try to remove all folder bin and obj then using command msbuild to build for first shot and got issue dotnet msbuild ClientAppProgram.csproj -t:Restore;Build I check output in bin of ClientAppProgram and found missing generate assemblyBinding for ClientAppProgram but FooProgram has. But IF I clean all folder bin and obj then i try separate into 2 commands dotnet msbuild ClientAppProgram.csproj -t:Restore dotnet msbuild ClientAppProgram.csproj -t:Build

Then the assemblyBinding are generated for both appliation or I try rerun again command above still generated. So it's strange that why the assemblyBinding never generate for 1 build command at first time.

Steps to Reproduce

  • Run command dotnet msbuild ClientAppProgram.csproj -t:Restore;Build to build ClientAppProgram then to to bin/debug/net472 to verify ClientAppProgram.exe.config must has assemblyBinding

Expected Behavior

  • assemblyBinding must generate for both mulit-target command: restore;build; for ClientAppProgram.exe.config

Actual Behavior

  • assemblyBinding only generate if run 2 target in 2 separate command. so if run 1 command cause missing

Versions & Configurations

  • I try both dotnet msbuild and msbuild from visual studio and got same issue.

Program to verify: FooProgram.zip

tangkhaiphuong avatar May 08 '22 14:05 tangkhaiphuong

Team Triage: Does this issue repro if you do msbuild /restore /t:Build?

benvillalobos avatar Jul 14 '22 16:07 benvillalobos

This issue is marked as stale because feedback has been requested for 30 days with no response. Please respond within 14 days or this issue will be closed due to inactivity.

ghost avatar Aug 14 '22 00:08 ghost

This issue was closed due to inactivity. If you can still reproduce this bug, please comment with the requested information, detailed steps to reproduce the problem, or any other notes that might help in the investigation.

ghost avatar Aug 28 '22 19:08 ghost