optimizely / csharp-sdk

.NET based C# SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/csharp-sdk
Apache License 2.0
19 stars 20 forks source link

csharp-sdk does not build for UWP apps #272

Closed adiaz-msft closed 3 years ago

adiaz-msft commented 3 years ago

Create a new "Blank App (Universal Windows)" C# UWP app using VS-2019 using default parameters. add Optimizely.SDK 3.9.1, NuGet package from https://www.nuget.org/packages/Optimizely.SDK

Add some simple calls to initialize SDK. Try to build x86 or x64 give same errors: Severity Code Description Project File Line Suppression State Error Could not copy the file "obj\x86\Debug\App.xbf" because it was not found. OptimizelyUWPTest
Error Could not copy the file "obj\x86\Debug\MainPage.xbf" because it was not found. OptimizelyUWPTest
Error Could not copy the file "obj\x86\Debug\OptimizelyUWPTest.xr.xml" because it was not found. OptimizelyUWPTest
Error Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.' OptimizelyUWPTest C:\Users\angel\ms-src\Scratch\Optimizely\OptimizelyUWPTest\OptimizelyUWPTest\OptimizelyUWPTest.csproj

Note that a C# .NET Core console app does work.

See attached test project. OptimizelyUWPTest.zip

dustin-sier commented 3 years ago

I was able to reproduce what you were seeing immediately.

Based on the error(s) that were occurring I wanted to confirm that a plain project would compile. I removed the Optimizely SDK and as expected it compiled successfully. I then re-added the SDK via NuGet and was shocked that the project compiled and ran as expected.

I've filled a bug report with Microsoft with Visual Studio: https://developercommunity.visualstudio.com/t/error-when-trying-to-build-uwp-app-after-adding-sd/1516205

Currently the best way to work around this is to add the Optimizely SDK after you've correctly built the existing UWP project.

srdjanjovcic commented 3 years ago

This is issue with .nuspec of Optimizely.SDK. It should declare a dependency on System.Configuration.ConfigurationManager

dustin-sier commented 3 years ago

I'll double check on this. Thanks for the additional info @srdjanjovcic

dustin-sier commented 3 years ago

@srdjanjovcic can you provide some additional information on why this build would work on additional builds? It seems interesting that the errors are intermittent.

srdjanjovcic commented 3 years ago

I do not know why it was working after a specific build, but bug as described does not repro if Optimizely.SDK contains a dependency on System.Configuration.ConfigurationManager.