How can I use BeforeBuild and AfterBuild targets with Visual Studio 2017?

前端 未结 3 1412
野趣味
野趣味 2020-12-30 23:59

After upgrading to a csproj to use Visual Studio 2017 and Microsoft.NET.Sdk, my \"BeforeBuild\" and \"AfterBuild\" targets are no longer running. My file looks like this:

3条回答
  •  难免孤独
    2020-12-31 00:52

    When you specify Project Sdk="Microsoft.NET.Sdk", you are using "implicit top and bottom imports". This means there is an invisible Import to Microsoft.NET.Sdk/Sdk.targets at the bottom of your csproj file which is overriding the "BeforeBuild" and "AfterBuild" targets.

    You can fix this by using explicit imports so you can control the import order.

    
    
      
    
      
        net46
      
    
      
    
      
      
          
      
    
      
          
      
    
    
    

提交回复
热议问题