Replies: 1 comment 1 reply
-
There is unfortunately no documentation on this. We have two distributions of MSBuild + enough other stuff to work. .NET SDK uses the Runtime package and packages a bunch of other stuff--but we don't have a clear picture of how much of that stuff is required, because that understanding is not required to build the SDK, which may need the stuff for other reasons. Likewise, Visual Studio ships MSBuild (the bits built from this repo) packaged in a VSIX file + many, many other things, defined in an internal-to-Microsoft graph that also doesn't have clear delineations on what is required. It's likely possible to assemble enough open-source bits to get the functionality of the .NET SDK in your own distribution, but that sounds very difficult to me. So difficult that I would not do it, in favor of requiring that the .NET SDK be installed. |
Beta Was this translation helpful? Give feedback.
-
Hey there,
as the title says I'm basically trying to ship a self-contained application built with .NET with MSBuild so the users of my program do not need to install Visual Studio or MSBuild themselves. The description of the
Microsoft.Build.Runtime
NuGet package basically says it does exactly that, and then states that there have to be additional steps to achieve this. I could not find a single bit of documentation on how to achieve that, so I've been struggling through some issues along here.What I have achieved so far:
I have looked into what
MSBuildLocator
does for registering Visual Studio instances, and registered the following environment variables:MSBUILD_EXE_PATH
to theMSBuild.dll
shipped with my application,MSBuildExtensionsPath
to the folder where the MSBuild.dll is located andMSBuildSDKsPath
to a sub folder called Sdks in that path. MSBuild.dll is located in my application folder with the rest of everything .NET related. That by itself obviously doesn't do all the trick.After adding the
Microsoft.Build.NuGetSdkResolver
package that was then required, I failed when MSBuild could not locate theMicrosoft.NET.Sdk
sdk definition when I tried to load a project.Here's issue number 1: Into my Sdks folder I manually copied the
Microsoft.NET.Sdk
andMicrosoft.NET.ILLink.Tasks
Sdks and set the environment variableMSBuildEnableWorkloadResolver
to false. This made the project load because the definitions were there. But manually copying these is really bad, and ideally I don't want to clutter my Git with these files. So is there a better way to include these definitions? I got them from my installation of .NET 6.0So, going on, the project finally loaded. But what am I trying to do with the project? I want to restore it. However, after calling
CreateProjectInstance
on myMSBuild.Evaluation.Project
file I got from parsing and checking, whether the targetRestore
does exist in the defined Targets I found out that it doesn't. No restore for my projects since the target doesn't exist is quite odd, so what things am I forgetting that I cannot do that.Alternatively to
Restore
I tried the targetBuild
and now I get a build failure as a result. Adding a logger to my build request reveals the error message that reads:The "ProcessFrameworkReferences" task was not given a value for the required parameter "RuntimeGraphPath". @MSBuildPath\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets:90
. Edit: This was solved by copying the missing fileMicrosoft.NETCoreSdk.BundledVersions.props
into the root directory. This made the build start, however the build is now reporting that a NuGet restore is required. The restore still is not present in the project's targets.I'm at a loss on how to continue or how to include MSBuild with my application, so I hope someone can help me continue. Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions