firstfloorsoftware/xcc

Functionality broken with update to 2.2.0.31 ?

Closed this issue ยท 29 comments

taori commented

Hi,

I've experienced an issue after updating my Xamarin.

Xamarin.Forms.Xaml.XamlParseException: Position 12:14. MarkupExtension not found for d:DesignInstance

is appearing again. Could it be that xamarin changed something which breaks 1.0.7 of xcc?

taori commented

would you be willing to take a PR for this? I could try and have a look at what exactly is going wrong here if you don't have the time right now

kozw commented

You're probably right. Haven't touched the code for a long time, things move quickly at Xamarin's end.

A PR is most welcome, please do!

Thanks

Yeah, started running into this yesterday. The XAML files in preprocessedxaml look correct, but Xamarin must be pulling the originals from somewhere else or something.

taori commented

I can only confirm what jherby2k said. I also checked out xcc to run it side by side within the test solution. Still need to figure out why the debugger won't attach though.

taori commented

image

... or at least it used to. That's as far as i've gotten right now. Maybe it's better if kozw fixes this. I am sure he's far more competent with msbuild here.

taori commented

I have identified the following changes in the xamarin targets file: (left: 2.2.0.31, right: < 2.x)

bottom part of the targets file:
image

top part of the targets file:
image

the build task of yours works the same as before, so i guess it's the changes in xamarins target file which broke your plugin.

according to https://github.com/firstfloorsoftware/xcc/blob/master/FirstFloor.Xcc/Targets/Xcc.targets

WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy.

I suppose this is a change which you(@kozw) would rather do yourself :)

I am having the same problem. The preprocessedxaml file is correct but never replaces the original .xaml file.

kozw commented

This do-not-modify-warning does not mean I won't take PRs :) On the contrary

Will look into this, not sure when, but I will

taori commented

@kozw i guess. however in comparison to your knowledge about how to properly manipulate the targets file your knowledge most certainly exceeds mine (because i dont want to end up breaking other platforms)

For anyone else looking for a temporary workaround:

Changing the target to this:
<Target Name="GenerateXaml" BeforeTargets="BeforeBuild;BeforeRebuild">

will work in a xamarin pcl project.

Sorry @taori, where exactly do I set that target line?

taori commented

@jherby2k check for where xcc was deployed through nuget and find the Xcc.Targets file. If you replace the lines accordingly the correct xaml file should be used for compilation (at least it did work for me on the xamarin platform)

taori commented

@kozw if you think my workaround can be used as a fix for the problem itself on all platforms - feel free to let me know. I just dont want to do this as PR yet, since i'm not sure about it not breaking other project types.

@taori

BeforeBuild;BeforeRebuild worked only on the first build for me, after playing around with the targets I came up with:
<Target Name="GenerateXaml" BeforeTargets="BeforeBuild;XamlG;MarkupCompilePass1" AfterTargets="_PreXamlG;CoreClean">
which seems to work much better. I know nothing about MSBuild targets to be completely honest, so I'm not sure if that will help. Would you mind reviewing it?

taori commented

@jasoncouture To be honest when it comes to manipulating targets files i would still consider myself an advanced noob, too. This issue made me learn things which i didn't know previously - so i'm not an appropriate person to give you a review unfortunately.

From what i understood a target will only run once, as soon as possible, while not violating AfterTargets in terms of call order. Thus your Target declaration looks ok too.

(Though for me BeforeBuild;BeforeRebuild works without any issues for me too - not sure why it doesn't for you). I guess we'll have to see if @kozw comes up with something which also works in general.

@taori In my build, it was calling the target CoreClean AFTER it was creating the temporary XAML files in obj/, this would then delete them, and when Xamarin went to compile the files, they went missing and the build would fail.

Removing Before BeforeRebuild and adding After CoreClean (the target that was deleting things) prevented that from occuring.

Thanks for the input!

taori commented

@jasoncouture well that's interesting. It's kinda weird it works for me but doesn't for you. but i'm glad you got it working anyways :)

I had the same problem as @jasoncouture but his solution also worked for me:

Thanks!!

kozw commented

Thanks guys, this thread contain useful info to tackle the msbuild issues, which I can use to make xcc work for all platforms.

taori commented

@kozw i tried setting up a test case environment to verify compilation success for the listed supported platforms, but wasn't happy with my results yet. What's your thought on this for the future?

My thought was something like:

Per case csproj file > msbuild compile > verify compilation result against expected.xaml. However i didn't want to mess around with the test project all that much without talking to you first (That and midway i lost my motivation)

That way it would be rather easy to adapt to potential future changes (given that i can imagine, you didn't want this to be this much work in your free time)

kozw commented

The test project does not include tests where MSBuild compiles the supported platforms and their various versions. I think this somehow should be included in the test project. Your idea sounds like what I would try.

In my case, after doing a little digging, it looks to me like Xamarin changed the name of that MarkupCompilePass1 to XamlMarkupCompilePass1. I simply changed the line in the xcc.targets file in my nuget packages folder from

  <Target Name="GenerateXaml" BeforeTargets="MarkupCompilePass1" AfterTargets="_PreXamlG">

to

  <Target Name="GenerateXaml" BeforeTargets="XamlMarkupCompilePass1" AfterTargets="_PreXamlG">

and everything seems to work pretty much the way it did before. I don't know how to make it check for multiple targets tho (e.g. for earlier versions) coz I'm a total msbuild n00b, e.g.

  <Target Name="GenerateXaml" BeforeTargets="MarkupCompilePass1;XamlMarkupCompilePass1" AfterTargets="_PreXamlG">

maybe? but I'm hoping someone here might be able to take that ball and run with it...

I've put in a PR for it anyway.

I did find

https://github.com/KirillOsenkov/MSBuildStructuredLog/wiki/MSBuild-Tips-&-Tricks

and

https://github.com/KirillOsenkov/MSBuildStructuredLog

to be a massive help though, when doing this (the projects-inlining /pp: parameter to msbuild was what helped me the most tho)

taori commented

@wislon let's hope @kozw finds the time to look at it and publish a fix :) Nice find on that tool btw and thanks for sharing it. Certainly would have been a big help for me too, hehe.

kozw commented

PR looks good, but backwards compatibility (as mentioned) is something worth investigating before I can accept it

@kozw totally expected (and accepted), like I said: hopefully someone can take the ball and run with it into areas I don't know how to go to. thanks for your consideration ๐Ÿ˜„

@taori thanks, yeah, I picked it up off one of Scott Hanselman's blog posts a while back, and thought I'd aim it at this problem and see what it came up with... ๐Ÿ˜„

Any further details on this? Happy to assist however i'm looking to add this to a new project so testing backwards functionality isn't something i can probably test...

kozw commented

PR accepted and new release on NuGet. I've done some tests and it looks like the fix works great

@kozw you, sir, are a scholar and a gentleman! thank you very much indeed! ๐Ÿ‘

@kozw thanks! good work ๐Ÿ’ƒ

taori commented

@wislon thanks for your PR.