private void UpdateFramework(JObject json)
        {
            var frameworks = JsonConfigUtility.GetFrameworks(json);

            if (InternalMetadata.TryGetValue(NuGetProjectMetadataKeys.TargetFramework, out object newTargetFramework))
            {
                if (IsUAPFramework(newTargetFramework as NuGetFramework) && frameworks.Count() == 1)
                {
                    // project.json can have only one target framework
                    JsonConfigUtility.ClearFrameworks(json);
                    JsonConfigUtility.AddFramework(json, newTargetFramework as NuGetFramework);
                }
            }
        }
        public void JsonConfigUtility_ClearFrameworks()
        {
            // Arrange
            var json = BasicConfig;

            var frameworks = JsonConfigUtility.GetFrameworks(json);

            Assert.Equal("netcore50", frameworks.Single().GetShortFolderName());

            // Act
            JsonConfigUtility.ClearFrameworks(json);
            frameworks = JsonConfigUtility.GetFrameworks(json);

            //Assert
            Assert.Equal(0, frameworks.Count());
        }
Beispiel #3
0
        private async Task UpdateFrameworkAsync(JObject json)
        {
            // Update the internal target framework with TPMinV from csproj
            await UpdateInternalTargetFrameworkAsync();

            if (TryGetInternalFramework(out object newTargetFrameworkObject))
            {
                var frameworks         = JsonConfigUtility.GetFrameworks(json);
                var newTargetFramework = newTargetFrameworkObject as NuGetFramework;
                if (IsUAPFramework(newTargetFramework) &&
                    frameworks.Count() == 1 &&
                    frameworks.Single() != newTargetFramework)
                {
                    // project.json can have only one target framework
                    JsonConfigUtility.ClearFrameworks(json);
                    JsonConfigUtility.AddFramework(json, newTargetFramework as NuGetFramework);
                }
            }
        }