-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XAML files are not supported #1467
Comments
From @tannergooding on February 3, 2017 22:56 FYI. @srivatsn, @jinujoseph, @nguerrera |
From @tannergooding on February 3, 2017 22:57 This completely blocks the porting of WPF based applications to CPS (I imagine it would also block UWP and anything else that uses XAML). |
Yes WPF and any other desktop projects are not supported yet. Currently only .NET Core projects are supported. |
This should work with the right |
For me it works good with VS2017 RC and the class library project (.NET Framework, not .NET Standard). I can include XAML files and everything is properly compiled, Intellisense works, etc. UPD. I also checked default class library project (the template with .NET Standard). After switching target to net461 it works but indeed it treats XAML as |
I was able to properly setup XAML files building with CPS for VS2017. |
Ok. I now understand this much better (@srivatsn). WPF (and some other project types) generate a temporary project file that does not use the same extension as the original (WPF uses .tmp_proj, for example). The SDK.targets uses the project extension to set So the workaround is to ensure that I would think the proper fix, however, is to get the XAML targets (and any other targets that generate temporary projects) to use the original project extension. |
@tannergooding, WPF is using temporary project because it need two-pass building to properly process XAML markup as described in this article on MSDN. So I'm afraid it might not be possible to avoid |
@aienabled Keep any bugs you file for managed concepts on this repro. |
@aienabled, i wasn't indicating it should avoid .tmp_proj, I'm saying t should usee the original projects file extension when doing so. Meaning instead of .tmp_proj, it should use .tmp_proj.csproj or just .csproj. |
@tannergooding can you file that as an internal bug on XAML? |
@srivatsn, I have logged VSO Bug: 382095 (not sure if the area path is correct, it seemed to be the best fit though). |
XAML needs PresentationBuildTasks, right, so is it correct that making this work in the SDK won't automatically make it work with |
Related: dotnet/sdk#1367 |
Workaround in RepoToolset (included via Directory.Build.props): <Choose>
<When Condition="'$(MSBuildProjectExtension)' != '.csproj' and '$(MSBuildProjectExtension)' != '.vbproj'">
<PropertyGroup>
<LanguageTargets Condition="Exists('$(MSBuildProjectDirectory)\$(AssemblyName).csproj')">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
<LanguageTargets Condition="Exists('$(MSBuildProjectDirectory)\$(AssemblyName).vbproj')">$(MSBuildToolsPath)\Microsoft.VisualBasic.targets</LanguageTargets>
</PropertyGroup>
</When>
</Choose> Turns out the XAML build sets the |
Anyone got this working? I'm able to compile it but I lost intellisense in VS 2017. This is my csproj: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<OutputType>winexe</OutputType>
<TargetFramework>net462</TargetFramework>
<DebugType>Full</DebugType>
<ApplicationIcon>res\ico\icon.ico</ApplicationIcon>
<OutputTypeEx>winexe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TransformOnBuild>True</TransformOnBuild>
<TransformOutOfDateOnly>false</TransformOutOfDateOnly>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />
<ItemGroup>
<!-- App.xaml -->
<ApplicationDefinition Include="App.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" />
<!-- XAML elements -->
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Compile Include="$(IntermediateOutputPath)**\*.g.cs" Visible="false" />
<None Include="$(ProjectDir)obj" Visible="false" />
<!-- Resources -->
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />
<!-- Settings -->
<None Update="Properties\Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
<Compile Update="Properties\Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
<None Update="App.config">
<TransformOnBuild>true</TransformOnBuild>
</None>
<None Update="App.Debug.config">
<IsTransformFile>True</IsTransformFile>
</None>
<None Update="App.Release.config">
<IsTransformFile>True</IsTransformFile>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Publish\**" />
<EmbeddedResource Remove="Publish\**" />
<None Remove="Publish\**" />
<Page Remove="Publish\**" />
</ItemGroup>
<PropertyGroup>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
</PropertyGroup>
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
</Project> |
❓ @bdovaz I notice you have Here's one project that I've been working on that uses XAML. I need to look back and see if IntelliSense is working properly. |
@sharwell to be honest I don't know, my csproj is being written by seeing other people examples that are trying to achieve the same goal. Also when I mean intellisense I mean that I can't reference almost anything. Example: Note: The code that is not recognizing it's in another referenced project. I really want to use the new format but I need a working example that works. One example that:
I've tried to update my csproj seeing that example but I have the same problem: it compiles but I have no Intellisense. Any help? |
@bdovaz, Do you need this for WPF/UWP or Xamarin project? |
@sharwell I managed to get something to work within the past 24 hrs.. but it does not contain that target rule like mentioned in my previous thread. That target breaks my project. Here is what I have: <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<LanguageTargets Condition="Exists('$(MSBuildProjectDirectory)\$(AssemblyName).csproj')">$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
<OutputType>WinExe</OutputType>
<TargetFramework>net471</TargetFramework>
<StartupObject>HearthStone.UnInstaller.App</StartupObject>
<PackageId>HearthStone.UnInstaller</PackageId>
<AssemblyName>HearthStone.UnInstaller</AssemblyName>
<RootNamespace>HearthStone.UnInstaller</RootNamespace>
<Version>1.0.0</Version>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
<!-- App.xaml -->
<ApplicationDefinition Include="App.xaml" SubType="Designer" Generator="MSBuild:XamlIntelliSenseFileGenerator" />
<!-- XAML elements -->
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Compile Update="$(IntermediateOutputPath)**\*.g.cs" Visible="false" />
</ItemGroup>
</Project> The |
Could you replace your |
@DNF-SaS Interesting, I missed that difference. I use the same form you did: |
@Latency I would strongly suggest you use my My objective with that package is to fill the box and make it clean/simple to use with SDK style projects until there's direct support from Microsoft. |
@sharwell I'll give you the same advice too for ILSpy ;) Iet's keep our efforts/workarounds consolidated if we can. |
@onovotny I will be happy to give that a try.. It looks solid! To be clear, I am removing the entire On initial compile.. it appears to pass the pre-checks. Since, my project is broke down for reconstruction on a major build ATM, I have lots of debugging to do.. and can not validate this! What I can tell you is that something is missing from being able to compile the XAML files now after using your .nupkg. I am getting missing references to override OnClosing() in a few of my XAML files and about 100 less errors than my version which seems suspicious. I am not sure what order the compiler is checking things here. Q: I assume that I would need to resolve these OnClosing() issues before seeing the other 100 problems with the project that still remain to be debugged? Q: What am I missing now and which of these rules I posted redundant in your package? (too busy to investigate) I have had to revert to keeping the rules from my above listed example to finish debugging my project until I can get a more clarity on which rules I must keep in conjunction with your Q: Is the Q: For Blend 2017, it appears it is not supporting the new build configuration formats. Any thoughts regarding that? Are we supposed to wait for a fix from Microsoft on this? |
Tried to convert a XAML project to the new project format today and neither the |
There is imperfect XAML support already in the 3.0 nightly builds - pre-alpha stuff, but it’s definutely being implemented. I would expect full support (designer etc) to require vs2019. In the meantime, the workarounds people have described above are still functioning; I have a bunch of WPF libraries and applications using SDK projects. |
Project system support, as per our roadmap https://github.com/dotnet/project-system/blob/master/docs/repo/roadmap.md, is in the 16.x timeframe. |
Closing this as Xaml is now well supported in 16.1 and we have individual issues for the few gaps that remain. If there is a comment in this thread that represents something that is still an issue in Visual Studio 2019 please log a new issue. The issues that are still pending for Xaml support can be tracked here: https://github.com/dotnet/project-system/issues?q=is%3Aopen+is%3Aissue+label%3AFeature-XAML Other teams will also have work pending (eg. the designer) but the workarounds called out in this thread should generally be no longer needed. |
I posted possible (nasty) workaround for the issues with 2-pass build here: #5252 |
From @tannergooding on February 3, 2017 22:56
Attached is a simple repro solution.
WpfCps.zip
Issue 1: XAML files are treated as
None
, when they should be treated asPage
withGenerator=MSBuild:Compile
andSubType=Designer
metadata.Issue 2:
Page
items are not visible in the Solution ExplorerIssue 3: xaml.cs files are not properly nested under the xaml file
Issue 4: Compilation fails with:
1>C:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(419,45): error MSB4057: The target "CoreCompile" does not exist in the project.
Copied from original issue: dotnet/sdk#810
The text was updated successfully, but these errors were encountered: