dotnet / dotnet/msbuild

Msbuild seems to not exactly rebuild the unique solution like what VS does.

Open
#4,594 2 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

### Steps to reproduce

1. In VS2017, create a Class Library called Library1 (C# .net framework 4.0)
2. Use Packages.config format to consume a nuget package **microsoft.bcl.async** 1.0.168 version
3. In default Class1.cs file I have content:
```c#
public class Class1
{
static void TestMethod1()
{
Console.WriteLine("Have a nice day");
}
}
```

4.Then I create a new empty web site(C# .net framework 4.0), right-click the web-site to add reference to Library1, now right-click the solution=>rebuild the solution everything works well.

The Library rebuilds successfully, and the website successfully copy the latest Library1.dll to bin folder and PreCompile folder.

5.Now if I add some async methods into the Library1. The rebuild in VS works well with no warnings. code:

```C#
public class Class1
{
static void TestMethod1()
{
Console.WriteLine("Have a nice day");
}
static async Task F() => await TaskEx.Delay(100);
static void TestMethod2() => F().Wait();
}
```

### Expected behavior
Since the rebuilding solution in VS works well, now I want the msbuild command-line also works so that I can automate managing it.

### Actual behavior
However if now I use msbuild command-line, open developer command prompt for VS2017 and navigate to solution folder(cd path), use command: **msbuild xxx.sln /t:rebuild** it throw warnings like:
```
(Rebuild target) ->
C:\Users\xxx\source\repos\Library\WebSite1_1_.metaproj : warning MSB3268: The primary reference "C:\Users\lancel\s
ource\repos\Library\Library\bin\Debug\Library.dll" could not be resolved because it has an indirect dependency on the f
ramework assembly "System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not
be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove t
he reference "C:\Users\xxxx\source\repos\Library\Library\bin\Debug\Library.dll" or retarget your application to a fra
mework version which contains "System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
```

And exactly the Library1.dll is not the latest one. Simple code in Library1.dll and the msbuild command-line works well and website will copy the latest Library1.dll. Async code in library1's class1.cs, and then the msbuild command-line won't work as I expected.

What confused me:

As it always works well when building in VS, so actually I try to make it still work in msbuild command-line, but I failed to do that. It only works when I use devenv.exe instead of msbuild.exe. Any hint would be appreciated!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.