2
votes
  1. Create wpf app .net 4.6.1 (by console app it is not reproducible on my machine).
  2. Reference Microsoft.Build 14.3.0 (but the same issue with latest version as well) nuget package

Run this code (replace with real *.proj file):

public MainWindow()
{
    InitializeComponent();
    Loaded += (sender, args) => BuildManager.DefaultBuildManager.Build(new BuildParameters(),
        new BuildRequestData(@"e:\Tests\ConsoleApp7\ConsoleApp7\ConsoleApp7.csproj", new Dictionary<string, string>(), null,
            new[] { "Build" }, null, BuildRequestDataFlags.ReplaceExistingProjectInstance));
}

It is okay for me now

  1. Reference the latest Microsoft.Web.Administration nuget package.
  2. Run the same code. As result I get the following exception:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

Inner Exception: FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

What is the best way to resolve it?

1

1 Answers

1
votes

I am having a very similar issue using Microsoft.Web.Administration 10.0.0 (latest at time of writing) within a WiX installer project. I've been having this issue only after I have updated from VisualStudio 2017 15.2 to 15.4, so I am not entirely sure this is exactly the same problem you are experiencing, but the exception is the same.

Unfortunately my solution has been to downgrade to Microsoft.Web.Administration 7.0.0. I have contacted the owner of the nuget package and I am awaiting a better explanation from them, however I hope this might help you for the moment!