locked
Xamarin Android project in Visual Studio .csprop file cyclic loading error RRS feed

  • Question

  • User3024 posted

    The default csropj is ``` xml Debug AnyCPU 8.0.30703 2.0 {EC2A2426-C4D0-4E96-9601-4B1FBFC5B04C} {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Library Properties App1 App1 512 True Resources\Resource.Designer.cs Off True v6.0 Properties\AndroidManifest.xml True Full False bin\Debug\ DEBUG;TRACE prompt 4 True None False

    PdbOnly True True bin\Release\ TRACE prompt 4 False SdkOnly True ```

    But I want to use diff AndroidManifest in diff Build Configuration. So my csproj like:

    xml <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{EC2A2426-C4D0-4E96-9601-4B1FBFC5B04C}</ProjectGuid> <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>App1</RootNamespace> <AssemblyName>App1</AssemblyName> <FileAlignment>512</FileAlignment> <AndroidApplication>True</AndroidApplication> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> <TargetFrameworkVersion>v6.0</TargetFrameworkVersion> <!------------No AndroidManifest here----------------------> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>True</DebugSymbols> <DebugType>Full</DebugType> <Optimize>False</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> <AndroidLinkMode>None</AndroidLinkMode> <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest><!---------------This Line----------------> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>PdbOnly</DebugType> <DebugSymbols>True</DebugSymbols> <Optimize>True</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidLinkMode>SdkOnly</AndroidLinkMode> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest><!---------------This Line----------------> </PropertyGroup>

    It works well with Xamarin earlier v4.2. But when I update to 4.4, The Visual Studio (2015/2017 both) will cyclic loading .csprop file , loading , reloading,reloading.......

    Tuesday, April 11, 2017 3:13 AM

All replies

  • User904 posted

    @ZouJian This sounds like a bug to me, I have filed it on the Bugzilla here https://bugzilla.xamarin.com/show_bug.cgi?id=54999

    But I want to use diff AndroidManifest in diff Build Configuration. What tool are you using to updated manifest file for different build configuration? Can't you leave the AndroidManifest element in the csproj file for time being?

    I am trying to find a workaround, I will keep you updated on the progress

    Tuesday, April 11, 2017 7:37 AM
  • User3024 posted

    @prashantvc I didn't remove the AndroidManifest element in csproj.

    I moved the AndroidManifest element from global PropertyGroup element to current Build Configuration Condition PropertyGroup element.

    Tuesday, April 11, 2017 10:29 AM
  • User3024 posted

    :) @prashantvc My biz scene like this:our app will build for different customers with different packagename and versionname, and other small amounts of code.

    I wrote a powershell script to create new BuildConfig.

    1. create a new AndroidManifest.xml and control it's versionName.
    2. create a new Budil Configuration property group in csproj file.
    Tuesday, April 11, 2017 10:33 AM
  • User904 posted

    create a new AndroidManifest.xml and control it's versionName.

    You can still create a new AndroidManifest.xml replace it before the build in your powershell script, can't you? That way you can avoid this issue until we confirm/prioritise the bug :smile:

    Tuesday, April 11, 2017 10:48 AM
  • User3024 posted

    This problem will not cause me to be unable to work. There is a strange problem of loop loading when just open the old version of the project.

    The solution I tried was add a global AndroidManifest first.

    ```xml Debug AnyCPU 8.0.30703 2.0 {F20138EF-4688-499B-9175-3BD3CF631DDB} {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest><!--like this -->
    

    ```

    And in my build configuation:

    xml <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-CompanyA|AnyCPU'"> <OutputPath>bin\Release-CompanyA\</OutputPath> <DefineConstants>TRACE;CompanyA</DefineConstants> <Optimize>true</Optimize> <DebugType>pdbonly</DebugType> <PlatformTarget>AnyCPU</PlatformTarget> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <AndroidManifest>Properties\AndroidManifest.CompanyA.xml</AndroidManifest><!--add a AndroidManifest with build config --> <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> <AndroidLinkSkip /> <AndroidLinkMode>SdkOnly</AndroidLinkMode> <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> <BundleAssemblies>True</BundleAssemblies> <AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> <AndroidSupportedAbis>armeabi-v7a</AndroidSupportedAbis> <AndroidStoreUncompressedFileExtensions /> <Debugger>Xamarin</Debugger> <AndroidEnableMultiDex>False</AndroidEnableMultiDex> <DevInstrumentationEnabled>True</DevInstrumentationEnabled> </PropertyGroup>

    It work well ,and the build result is the apk contains AndroidManifest.CompanyA.xml.

    Tuesday, April 11, 2017 11:08 AM
  • User3024 posted

    :) @prashantvc My biz scene like this:our app will build for different customers with different packagename and versionname, and other small amounts of code.

    I wrote a powershell script to create new BuildConfig.

    1. create a new AndroidManifest.xml and control it's versionName.
    2. create a new Budil Configuration property group in csproj file.

    xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="0" android:versionName="4.4.7.17" package="company.app.CompanyA"> <uses-sdk android:minSdkVersion="10" /> <application> <activity android:name="com.tencent.bugly.beta.ui.BetaActivity" android:theme="@android:style/Theme.Translucent" /> </application> </manifest>

    ```xml bin\Release-CompanyA\ TRACE;CompanyA true pdbonly AnyCPU Off prompt MinimumRecommendedRules.ruleset Properties\AndroidManifest.CompanyA.xml False SdkOnly True True False armeabi-v7a Xamarin False True

    <Content Include="Properties\AndroidManifest.CompanyA.xml">
      <SubType>Designer</SubType>
      <DependentUpon>AndroidManifest.xml</DependentUpon>
    </Content>
    

    ```

    Tuesday, April 11, 2017 7:54 PM
  • User574 posted

    This looks like a bug in the Visual Studio Addin. A work around might be to use use the following

        <AndroidManifest Condition=" '$(Configuration)' == 'Debug' "> Properties\AndroidManifest.xml</AndroidManifest>
        <AndroidManifest Condition=" '$(Configuration)' == 'Release' "> Properties\Release\AndroidManifest.xml</AndroidManifest>
        <AndroidManifest Condition=" '$(Configuration)' == 'CompanyA' "> Properties\CompanyA\AndroidManifest.xml</AndroidManifest>
    

    in the main property group rather than in each of the configurations.

    Alternatively you could use the $(Configuration) in the AndroidManifest.xml path

    <AndroidManifest Condition="Exists('Properties\$(Configuration)\AndroidManifest.xml')" >Properties\$(Configuration)\AndroidManifest.xml</AndroidManifest> 
    <AndroidManifest Condition=" '$(AndroidManifest)' == ''" >Properties\AndroidManifest.xml</AndroidManifest>
    

    This will make this a bit more generic. As long as the AndroidManifest.xml exists in a subdirectory of Properties\$(Configuration) should work. There is a fallback to use the default AndroidManifest if one in the $(Configuration) folder does not exists.

    Monday, August 7, 2017 10:12 AM