Open dazinator opened 6 years ago
You need many MSBuild "hacks" to get a vsix using the new project system, and there are many UI features missing for VSIX development. You need to import the VSSDK targets after importing Sdk.targets. This is the project I use, which has some "hacks" to make WPF work in the new project system too: https://github.com/CosmosOS/XSharp/blob/master/source/XSharp.ProjectSystem/XSharp.ProjectSystem.csproj
@jp2masa - thank you very much, this was very helpful. I now have the project building and producing a vsix :-)
One problem I have noticed, is that the VSIX is set to install the BuildSystem (targets, rules etc) to [INSTALLDIR]\MSBuild
However the project templates have this:
<CustomProjectExtensionsPath>$(LocalAppData)\CustomProjectSystems\XSharp\</CustomProjectExtensionsPath>
The build system is copied to LocalAppData on build, which is why this will work locally, but when installed via the VSIX it won't work.
Are you aware of any msbuild property that can be used within the project file that will point to [INSTALLDIR]\MSBuild
directory of the VS instance?
e.g I am looking for a property to use like this:
<CustomProjectExtensionsPath>$(VS INSTALL DIR)\MsBuild\CustomProjectSystems\XSharp\</CustomProjectExtensionsPath>
The build system is not finished, as for now it's a bit hard to ship a custom SDK. Currently the project system is usable only if targets are manually imported: https://github.com/CosmosOS/XSharp/blob/master/source/XSharp.Playground/XSharp.Playground.xsproj.
Rules and design time targets are installed to $(MSBuildExtensionsPath)
, and they are consumed by the SDK: https://github.com/CosmosOS/XSharp/blob/master/source/XSharp.Sdk/build/XSharp.Build.targets#L13.
Ah Ok thanks. MSBuildExtensionsPath
was the msbuild property I was looking for! Before that, I was using: $(DevEnvDir)..\..\MsBuild\
to refer to that same location :-)
Interesting. So MSBuildExtensionsPath
works in that it points to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild
when running under VS, and this is where the VSIX installs things too when using an InstallRoot
of MSBuild
- which is great.
However, if you then drop the command line and run a dotnet build
.. MSBuildExtensionsPath
doesn't point to that location any longer. So it ends up looking in: C:\Program Files\dotnet\sdk\2.0.0
(i.e the root directory of whichever version of the dotnet sdk you have installed) - and obviously the targets aren't deployed to this location by the VSIX. so it wont work. App Local Data
doesn't have this problem, but obviouilsy yuou cannot deploy to App Local Data via a VSIX so this isn't an option for me).
My build system does support dotnet core (all my tasks are compatible with both dotnet core and desktop msbuild), but I was hoping to streamline the installation by installing purely via a VSIX (i.e no msi).
The only way I can get this working with dotnet
sdk is to make the user specify this property i.e:
dotnet pack /p:PackageVersion=2.1.0 /p:MSBuildExtensionsPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild"
This then works, but it is not ideal.
If you are extending the dotnet project system, then the best option would be to ship the build system as a nuget package. If not, then I think it's not possible.
In the X# project system, only the design time targets and rules are installed in $(MSBuildExtensionsPath)
, because they are consumed by VS, but the rest of the build system will ship as an MSBuild SDK, which currently is limited, but will support SDKs coming from a NuGet package. PackageReference is implemented for the dotnet and legacy project systems only, and that's the best option to extend the build system at the moment.
@jp2masa - I have been using your example csproj file for a while: https://github.com/CosmosOS/XSharp/blob/master/source/XSharp.ProjectSystem/XSharp.ProjectSystem.csproj
However today I added an xaml file to my project, and it gives me some build errors. Just wondering if you might have come accross this:
Severity Code Description Project File Line Suppression State Error MC1002 Library project file cannot specify ApplicationDefinition element. DnnVsProjectSystem.ProjectType C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets 268
Severity Code Description Project File Line Suppression State Error BG1003 The project file contains a property value that is not valid. DnnVsProjectSystem.ProjectType C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets 268
It's odd because the Build Action
shows in the property pages window for the xaml
file as None
However in the csproj file it's clearly listed as Page
:
<ItemGroup>
<Page Include="Licence\LicenceScreen.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Update="Licence\LicenceScreen.xaml.cs">
<DependentUpon>LicenceScreen.xaml</DependentUpon>
</Compile>
</ItemGroup>
The designer seems to work fine.
If I change the Build Action
in the properties window to Page
- VS adds the following entry to the project file:
<None Remove="Licence\LicenceScreen.xaml" />
and it then becomes greyed out in solution explorer like it's been excluded from my project. Very odd!
What VS version are you using? Also, are you specifying any ApplicationDefinition
? I recently changed the project file a bit and now it imports some workarounds from Directory.Build.props
and Directory.Build.targets
, this version should work without any special imports: https://github.com/CosmosOS/XSharp/blob/a8c23c716b5995b40771535b6c9620a941aba0e9/source/XSharp.ProjectSystem/XSharp.ProjectSystem.csproj.
Ok thanks, I'll triple check over everything
@jp2masa - An csproj!
. Thanks to good old copying and pasting of files between projects.. Thanks for pointing me to the latest version.
@madskristensen or @rainersigwald would probably know who has the authority to create and publish a Microsoft.VisualStudio.SDK.Extensions
, named similar to those listed here: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview#available-sdks.
That will shave off a lot of xml lines from the world. Everyone would appreciate an SDK style VSIX csproj.
@madskristensen or @rainersigwald would probably know who has the authority to create and publish a Microsoft.VisualStudio.SDK.Extensions, named similar to those listed here: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview#available-sdks.
Let's ask @tinaschrepfer
@madskristensen I guess a lot of this will be internal MS / VisualStudio stuff - updating the custom editors to trigger on CPS project items and what have you, but if you want any help with testing or hooking this up - I did an SDK for the ASP.NET4 / MVC5 / OWIN / WebAPI2 world (to replace web application project) - it is available as MSBuild.SDK.SystemWeb
.
Some related resources are:
For some fun, I updated my
csproj
file for myProjectType
project (the one that produces a VSIX) to use the newSDK
format / style.In about half an hour I have the project building. Many references became
<PackageReference>
s.The main reason I wanted this is because I wanted to use
globbing
on includes to help resolve the problem in #167Sadly though, even though the project builds - when I check the output directory there is no
vsix
. Also it seems the xaml rules that allowed for properties like "IncludeInVsix" are no longer present as those options have disappeared from the property sheet.In brief.. Do you have any plans to provide templates based on the new format any time soon? So we can use new project system features?