dotnet / dotnet/project-system

Projects with workflow XAML do not compile

Open
#5,252 8 comments 4 reactions 0 assignees View on GitHub
Feature-XAML Parity-Legacy-Feature Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

**Visual Studio Version**: 16.2.0

**Summary**: Compiling project with XAML Service references fails with `The target "CoreCompile" does not exist in the project.`

**Steps to Reproduce**:

1. Have a project with XAML service references (`.xaml` file with Build Action: `Workflow definition`, Custom Tool: `MSBuild:Compile`) or (`.svcmap` file with Custom Tool: `Xaml Activity Generator` which generates `.xaml` files with Build Action: `XamlAppDef` and Custom Tool: `XamlIntelliSenseFileGenerator`)

2. Convert this project to new project format

3. Rebuild the project

**Expected Behavior**: Works, works always and works on first attempt

**Actual Behavior**: Build fails with error `C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets(333,43): error MSB4057: The target "CoreCompile" does not exist in the project.`
The build works if you do Rebuild + Build (i.e. 2nd time)

**User Impact**: Cannot convert projects with such files to new `.csproj` format. Cannot use new `.csproj` format consistently.
This si especially issue for compiling such projects on build servers as locally it can be worked around by building the project twice.

**More info**:
As has already been discussed on https://github.com/dotnet/project-system/issues/1467 under some circumstances projects containing `.xaml` files are build using 2-pass build. A temporary projects with extension `.tmp_proj` is generated and built in order to obtain some kind of reference assembly for the 2nd build (of the main `.csproj` project). Unfortunately the choice of extension (which is hard-coded in the task) confuses the new project system as it cannot determine from the `.tmp_proj` extension which language the project is (VB, C# or something else) and thus just some default common options are available. Specifying `` (`$(MSBuildToolsPath)\Microsoft.CSharp.targets`) does not solve the issue, just brings bunch error messages like
* `obj\Debug\net472\1ny23niw.AssemblyInfo.cs(14,12,14,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)`
* `obj\Debug\net472\1ny23niw.AssemblyInfo.cs(14,55,14,76): error CS0518: Predefined type 'System.String' is not defined or imported`
* `Service References\ChannelScheduleService\Reference.cs(182,6,182,12): error CS0518: Predefined type 'System.Object' is not defined or imported`
* `Service References\LookupService\Reference.cs(15,6,15,12): error CS0518: Predefined type 'System.Enum' is not defined or imported`
* `Service References\ReferenceDataService\Reference.cs(2642,156,2642,157): error CS0518: Predefined type 'System.Int32' is not defined or imported`
* `Service References\ReferenceDataService\Reference.cs(2642,150,2642,155): error CS0246: The type or namespace name 'Order' could not be found (are you missing a using directive or an assembly reference?)`
* `Service References\ChannelScheduleService\Reference.cs(15,51,15,60): error CS0246: The type or namespace name 'Namespace' could not be found (are you missing a using directive or an assembly reference?)`
* etc.

**Workaround**:
As I have observer that in case I do Rebuild + Build in Visual Studio the 2nd build passed, it seems to be possible to work around this issue by doing exactly that: Before build of the offending project try to build it and ignore any build errors. This can be achieved by following MSBuild code in the new `.csproj` file:
```xml








```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.