Skip to content
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

C#/WinRT Interop projects are always up-to-date regardless of their project dependencies #804

Closed
swesonga opened this issue Apr 14, 2021 · 0 comments · Fixed by #813
Closed
Assignees
Labels
bug Something isn't working fixed Issue has been fixed in an upcoming or existing release
Milestone

Comments

@swesonga
Copy link
Member

Summary:
C#/WinRT Interop projects are considered up-to-date after changing C++/WinRT Sources when fast Up To Date checking is enabled

Steps to Reproduce:

  1. Launch Visual Studio 2019 and go to Tools > Options > Projects and Solutions > SDK-Style Projects
  2. Ensure this option is checked: "Don't call MSBuild if a project appears to be up to date."
  3. Go to Extensions > Manage Extensions
  4. Search for “C++” then select C++/WinRT and click on “Download”
  5. Restart Visual Studio to complete the installation
  6. Create a new Windows Runtime Component (C++/WinRT) (called “CPPWinRTInteropRepro”, for example)
  7. Click OK to accept the default target and minimum platform versions (e.g. 19041 and 17763)
  8. Add a new C# Class Library (.NET Core) project called “CPPWinRTInteropReproProjection” to your solution.
  9. Delete the empty Class1.cs file from the project.
  10. Enable “Show All Files” for both projects in the solution explorer toolbar.
  11. In Solution Explorer, right click your class library project and select “Manage NuGet Packages”.
  12. Search for the “Microsoft.Windows.CsWinRT” NuGet package and install the latest version - https://www.nuget.org/packages/Microsoft.Windows.CsWinRT
  13. In Solution Explorer, right click the class library project and select “Edit Project File”.
  14. Update the TargetFramework element to reference the Windows SDK, e.g. “net5.0-windows10.0.19041.0”
  15. Add a new PropertyGroup to the project file with
    <PropertyGroup> <CsWinRTIncludes>CPPWinRTInteropRepro</CsWinRTIncludes> <CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata> </PropertyGroup>
  16. Save and close the CPPWinRTInteropReproProjection.csproj file.
  17. In Solution Explorer, right click the “Dependencies” node under the CPPWinRTInteropReproProjection project, select “Add Project Reference”, and select the CPPWinRTInteropRepro project.
  18. Add a new C# .NET 5 console application (e.g. ConsoleApp1).
  19. In Solution Explorer, right click the console application project and select “Edit Project File”.
  20. Change the TargetFramework to “net5.0-windows10.0.19041.0” to match the projection project.
  21. Add this property to ConsoleApp1: <PropertyGroup><CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata></PropertyGroup>
  22. Save and close the ConsoleApp1.csproj editor/window.
  23. Install the “Microsoft.Windows.CsWinRT” NuGet package into ConsoleApp1.
  24. In Solution Explorer, right click the “Dependencies” node under the ConsoleApp1project, select “Add Project Reference”, and select the CPPWinRTInteropReproProjection project.
  25. Add this code to Program.cs: var someObject = new Class();
  26. Add a using statement to the top of the file: using CPPWinRTInteropRepro;
  27. Build ConsoleApp1. This should succeed.
  28. Open Class.idl and add a new property (i.e Int32 NewProperty)
  29. Build the C++ project.
  30. Copy the generated class.h and class.cpp files into the main CPP project (copy the files from the folder Generated Files\sources to CPPWinRTInteropRepro ? and replace them ?).
  31. Remove the static asserts that cause build to fail (comment the line that contains static_assert in class.cpp and class.h)
  32. Build the C++ project, this should succeed.
  33. Build the C++ again, until the project is marked up-to-date
  34. Reference the newly added property in ConsoleApp1 (Add the statement someObject.NewProperty = 0 to Program.cs).
  35. Build ConsoleApp1.

Expected Behavior:
Building the console app (which depends on the interop project) should succeed.

Actual Behavior:
Building the console app fails.

User Impact:
Users need to rebuild the interops apps manually after changing the C++/WinRT sources.

C++/WinRT Resources:

  1. https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt
  2. https://docs.microsoft.com/en-us/windows/uwp/csharp-winrt/net-projection-from-cppwinrt-component

Version Info

  • CsWinRT 1.2.1
  • Visual Studio Version**: 16.9.0

Additional context
Copied from dotnet/project-system#7067

@swesonga swesonga added the bug Something isn't working label Apr 14, 2021
@Scottj1s Scottj1s self-assigned this Apr 15, 2021
@angelazhangmsft angelazhangmsft added this to the Release 1.2.4 milestone Apr 20, 2021
@angelazhangmsft angelazhangmsft added the fixed Issue has been fixed in an upcoming or existing release label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Issue has been fixed in an upcoming or existing release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants