Comments (25)
I can confirm SimpleStubs v2.4.5 fixes the build errors we were having with VS 2017 v15.6.x
from simplestubs.
@DustinCampbell @AndyGerlicher the MSBuildLocator solution seems to work well. Thanks for your help!
NuGet is up (2.4.5). Hopefully no one will report issues π
from simplestubs.
The reason I package MSBuild is because Roslyn needs the MSBuild dlls to work. I am not an MSBuild expert but there should be a way to allow Roslyn to link to the MSBuild dlls in the installed location directly. However, the problem would be for users who don't have that version of MSBuild installed.
from simplestubs.
Can you at minimum publish a package with MSBuild 15.6 to unblock people?
from simplestubs.
Yes, if Roslyn can work with 15.6. I will try to upgrade as soon as I find time and give it a try.
from simplestubs.
@nehmebilal: If you use the Microsoft.Build.Locator package that @AndyGerlicher mentioned, you do not need to deploy the MSBuild assemblies to make MSBuildWorkspace function. Instead, the locator will install an assembly resolution hook that will load the MSBuild assemblies from instance of MSBuild that you register. This will make your tool more resilient to changes in VS.
from simplestubs.
@DustinCampbell my experience with Roslyn is that if I donβt add assembly redirects to specific version of MSBuild, it usually fails. That said, I will give it a try and see what happens.
from simplestubs.
I will look at producing a small sample app for you to demonstrate if it would help.
from simplestubs.
That would definitely help. Thanks.
from simplestubs.
Here you go!
This is just a simple WinForms app. It does the following:
- Uses the Microsoft.Build.Locator package to register the default MSBuild instance on the machine.
- Uses MSBuildWorkspace to open solutions and projects.
- Dumps information to a text box.
You should be able to unzip the file, open MSBuildWorkspaceSample.sln
in VS 2017, restore packages and F5. Note that it has a custom post-build step to delete the following assemblies from the output:
Microsoft.Build.dll
Microsoft.Build.Framework.dll
Microsoft.Build.Tasks.Core.dll
Microsoft.Build.Utilities.Core.dll
Let me know if you need additional help to get this up-and-running. Also, I should let you know that we are in the process of overhauling MSBuildWorkspace. This will be a major (and breaking!) update and is in PR here: dotnet/roslyn#21670.
from simplestubs.
Thanks @DustinCampbell. I tried the tool and this is what I am seeing when I try to open a csproj:
Loading solution: C:\projects\SimpleStubs\test\TestClassLibraryTest\TestClassLibraryTest.csproj...
Loaded: 00:00:04.1057035
Errors:
[Failure] Msbuild failed when processing the file 'C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found. C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj
Project: TestClassLibraryTest (8 document(s))
I tried on other projects and solutions and I see a similar message.
from simplestubs.
Could you provide the full output?
from simplestubs.
Note that the instance of MSBuild that is registered is important. If that particular MSBuild doesn't have all of the workloads installed that the project you're loading requires, MSBuild won't be able to process the project.
from simplestubs.
MSBuild instances discovered:
1. Visual Studio Enterprise 2017 - 15.6.27428.2011
Registered: Visual Studio Enterprise 2017 - 15.6.27428.2011
Loading solution: C:\projects\SimpleStubs\test\TestClassLibraryTest\TestClassLibraryTest.csproj...
Loaded: 00:00:04.1057035
Errors:
[Failure] Msbuild failed when processing the file 'C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found. C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj
Project: TestClassLibraryTest (8 document(s))
I recently updated visual studio to 15.6. I'll try to create a brand new project and test on.
from simplestubs.
Did you restore that project first? MSBuildWorkspace will not run a dotnet restore
.
from simplestubs.
Also, do you have the .NET core development workload installed into VS?
from simplestubs.
MSBuild instances discovered:
1. Visual Studio Enterprise 2017 - 15.7.27517.0
Registered: Visual Studio Enterprise 2017 - 15.7.27517.0
Loading solution: D:\Projects\SimpleStubs\test\TestClassLibraryTest\TestClassLibraryTest.csproj...
Loaded: 00:00:02.4153010
No errors!
Project: TestClassLibraryTest (8 document(s))
from simplestubs.
Ok, I will do some more investigation and get back to you. Thanks.
from simplestubs.
@DustinCampbell Still doesn't work for me. I even tried adding the MSBuildSDKsPath as discussed here and restarted my visual studio instance.
I also verified the Visual Studio Installer and .Net Core Runtime component is installed (though I am not sure that it's reasonable to force users to have it installed to use SimpleStubs?).
Output from opening two different projects (notice the second error is different):
MSBuild instances discovered:
1. Visual Studio Enterprise 2017 - 15.6.27428.2011
Registered: Visual Studio Enterprise 2017 - 15.6.27428.2011
Loading solution: C:\projects\SimpleStubs\test\TestClassLibraryTest\TestClassLibraryTest.csproj...
Loaded: 00:00:04.9603597
Errors:
[Failure] Msbuild failed when processing the file 'C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj' with message: The imported project "C:\Program Files (x86)\MSBuild\2.0\Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\2.1.102\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props
Project: TestClassLibraryTest (8 document(s))
Loading solution: C:\Users\nbilal\Downloads\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample.csproj...
Loaded: 00:00:00.0440506
Errors:
[Failure] Msbuild failed when processing the file 'C:\projects\SimpleStubs\src\SimpleStubs\SimpleStubs.csproj' with message: The imported project "C:\Program Files (x86)\MSBuild\2.0\Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\2.1.102\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props
[Failure] Msbuild failed when processing the file 'C:\Users\nbilal\Downloads\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample.csproj' with message: The tools version "15.0" is unrecognized. Available tools versions are "14.0", "2.0", "3.5", "4.0". C:\Users\nbilal\Downloads\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample\MSBuildWorkspaceSample.csproj
Project: MSBuildWorkspaceSample (0 document(s))
C:\Program Files (x86)\MSBuild\2.0\Microsoft.Common.props
does not exist on my computer.
from simplestubs.
@AndyGerlicher : Do you have any ideas based on the error messages here?
@nehmebilal : In order to use MSBuild APIs (including MSBuildWorkspace), the various MSBuild tools must be installed on the user's machine.
from simplestubs.
@DustinCampbell in the meantime, it would be great if you can explain to me how do I figure out what version of MSBuild a particular version of Roslyn depends on? :)
from simplestubs.
You should not need to figure that out. That is actually a path of madness.
BTW: It turns out that my sample application ran into an MSBuild bug that can occur when using MSBuild APIs in an executable that has the text "msbuild" in its name. Here's a new version that should not exhibit that bug.
MSBuildWorkspaceSample - fixed.zip
from simplestubs.
Awesome π
Seems to work, I'll try it in SimpleStubs soon. Thanks.
from simplestubs.
I'm very glad to hear that!
from simplestubs.
This is great, thanks @nehmebilal and @DustinCampbell !!
from simplestubs.
Related Issues (20)
- Latest version does not compile when test project has x64-only project reference HOT 9
- Error Code 9009 when compiling HOT 2
- What should I do if I want to mock an object ? Order of Execution ? HOT 3
- SimpleStubs causes Visual Studio to freeze HOT 5
- SimpleStubs not generating stubs with generic Enum constraints correctly HOT 2
- Unused using directive when exculding interfaces HOT 3
- Configurable dir for SimpleStubs.generated.cs HOT 14
- No Intellisense for Stubs in VS2017 15.7.6 HOT 3
- Stubs not generated. HOT 2
- Generating stubs fails with ReflectionTypeLoadException: Unable to load one or more of the requested types HOT 15
- Unable to exclude vcxproj file HOT 5
- Upgrade to VS2019 - Stubs not generated HOT 16
- strong named version of dll HOT 6
- Preprocessing directives in namespace definitions not handled correctly HOT 3
- Simplestubs encountered errors when opening the workspace (referenced project platform different from test project) HOT 2
- Intellisense fails in VS 2019 for generated stubs HOT 3
- SimpleStubs fails in VS 2019 v16.7.0 HOT 4
- SimpleStubs fails in VS 2019 v16.7.5 HOT 3
- This repo is missing important files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplestubs.