visual studio 2022 excluding Android Manifest - xamarin.forms

I'm new here. i am testing visual studio for mac 2022. i am opening a xamarin project made in vs 2019 for mac. whenever I open it it deletes the android manifest and creates a new one. am i missing something?

I had the same issue and fixed it by updating the Android.csproj file with the configuration property groups created in a new VisualStudio 2022 Android project;
here's an example of one of the configuration tags I changed:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<LangVersion>9.0</LangVersion>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<MandroidI18n />
<AndroidTlsProvider>btls</AndroidTlsProvider>
</PropertyGroup>

Related

How to set OS condition for TargetFramework in MSBuild

I have few projects in my solution - few for mobile (Xamarin.Forms) and one xUnit. xUnit is build with .NET5 and references mobile project.
There are 2 pipelines on Azure DevOps to build mobile app. One is for Android and runs on Windows, another for iOS and runs on OSX.
xUnit project build started to fail after I added new NuGet to mobile project (Rg.Plugins.Popup).
Initially, setting the TargetFramework for xUnit project looked like this
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
That setup worked on OSX, but did not work on Windows with error message Error NETSDK1136: The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.
Changing it to
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
fixes Windows problem, but it starts failing on OSX (with same error message, which is weird, as we are no longer on Windows).
I tried few other options, but could not make it to succeed on both machines.
<PropertyGroup>
<TargetFramework Condition=" '$(OS)' == 'Windows_NT' ">net5.0-windows</TargetFramework>
<TargetFramework Condition=" '$(OS)' != 'Windows_NT' ">net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net5.0;net5.0-windows</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
I also tried with Choose, When and Otherwise, but it looks like you cannot wrap TargetFramework into that at all.
Am I doing it completely wrong or it it just some coincidence that correct code does not work in my case?
Try to place Condition inside PropertyGroup not TargetFramework .
Try the code below
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
</PropertyGroup>

Visual Studio 2017 ASP.Net Publish Self-Contained Dot Net Core App

I have a .Net Core ASP.Net application in Visual Studio 2017. I am trying to do a self contained deployment of the application.
If I run the following command from the CLI it works exactly how I want and produces a .exe
dotnet publish -c release -r win7-x64
However if I publish from Visual Studio 2017 it does not produce a .exe and produces a .dll instead.
How can I replicate the -r win7-x64 of the dotnet publish command from within Visual Studio 2017?
Here is the contents of my .pubxml
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<PublishFramework>netcoreapp1.1</PublishFramework>
<ProjectGuid>74bc47dd-6787-420d-804f-3f3d689d5ae5</ProjectGuid>
<publishUrl>C:\Deploy\JLM.MS.LeadGen.Dealer</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project>
This experience has been added to the publish window for Visual Studio 2017 version 15.3 (which can be downloaded here)
If you right click on your project -> Publish -> click the "Settings..." link under "Summary" -> go to the Settings tab of the Publish window, you should see a Target Runtime dropdown where you can choose which platform you want your app to run on. Here's a screenshot of what I'm talking about.
Make sure in your project file to include the runtime you want to select in <RuntimeIdentifiers> or <RuntimeIdentifier>, as the dropdown looks for these properties in order to populate its values.
You need to add
<OutputType>Exe</OutputType>
to your .csproj

Visual Studio 2015 (latest update) publish function does not compile ASP.NET Core RC1 sources

I begun working on a new ASP.NET Core RC1 project months ago, and Publishing with Visual Studio 2015, was producing a folder tree ready to deploy without the project C# sources (because it was compiling it in assemblies placed into the folder tree).
Now that I've upgraded the Visual Studio (only the VS, not the project that remains in 1.0.0-rc1-final) with latest updates (circa May, 19 2016):
"Microsoft .NET Core 1.0.0 RC2 - VS 2015 Tooling Preview 1", "Microsoft .NET Core 1.0.0 RC2 - SDK Preview 1 (x64)", "Microsoft ASP.NET 5 RC1 Update 1" (1.0.11123.0) and "Microsoft ASP.NET 5 RC1 Update 1" (1.0.20204.0)
it looks that the new Publish functionality of latest VS2015 updates, does not compile anymore the sources, instead it places into the Publish folder tree the project c# sources.
Can someone please indicate me how to force VS Publish functionality to compile again instead copying c# sources into the Publish Folders?
we removed this option ("Compile source files into NuGet packages") from the Publish dialog in rc2 tooling because this is not applicable for dotnet projects any more.
In order to publish an rc1 project with the –no-source option from VS, you can add this target to the pubxml (target needs to be inside the project and outside the propertygroup).
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<all your existing property group values>
</PropertyGroup>
<Target Name="DnuNoSourcePublish" AfterTargets="GatherAllFilesToPublish" Condition=" '$(CompileSource)' == 'true' ">
<Exec
Condition="Exists('$(PublishOutputPath)') and '$(PublishOutputPath)'!='' "
Command="rmdir /S /Q "$(PublishOutputPath)""
WorkingDirectory="$(MSBuildProjectDirectory)" />
<PropertyGroup>
<DnuCommand>"$(SDKToolingDirectory)\bin\dnu.cmd" publish</DnuCommand>
<RuntimeArgument Condition=" '$(FinalPublishVersion)' != '' " >--runtime $(FinalPublishVersion)</RuntimeArgument>
<WwwRootArgument Condition=" '$(WebRoot)' != '' " >--wwwroot $(WebRoot)</WwwRootArgument>
<WwwRootOutArgument Condition=" '$(WwwRootOut)' != '' " >--wwwroot-out $(WwwRootOut)</WwwRootOutArgument>
<IISCommandArgument Condition =" '$(IISCommand)' != ''">--iis-command $(IISCommand)</IISCommandArgument>
<NoSourceArgument Condition=" '$(CompileSource)' == 'true' ">--no-source</NoSourceArgument>
<NativeArgument Condition="'$(NativeFlag)' == 'true'">--native</NativeArgument>
<IncludeSymbolsArgument Condition=" '$(IncludeSymbolsFlag)' == 'true'">--include-symbols</IncludeSymbolsArgument>
<QuietArgument Condition=" '$(QuietFlag)' == 'true'">--quiet</QuietArgument>
</PropertyGroup>
<Exec
Command="SET PATH=$(ExternalToolsPath);#(DnuPublishEnvironmentVariables)
$(DnuCommand) "$(KPackWorkingDirectory)" --out "$(PublishOutputPathNoTrailingSlash)" --configuration $(PublishConfiguration) $(RuntimeArgument) $(WwwRootArgument) $(WwwRootOutArgument) $(IISCommandArgument) $(NoSourceArgument) $(QuietArgument) $(NativeArgument) $(IncludeSymbolsArgument)"
WorkingDirectory="$(KPackWorkingDirectory)"/>
</Target>
</Project>
Make sure your property group has this property set
<CompileSource>true</CompileSource>
Looking how VS was publishing prior to the RC2 updates, I noticed the two:
C:\Users\(user)\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnu.cmd publish "(destinationFolder)" --out "C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder)" --configuration Debug --no-source --runtime dnx-clr-win-x86.1.0.0-rc1-update1 --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web" --quiet
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:contentPath='C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder)\' -dest:contentPath='(destinationFolder)' -verb:sync -retryAttempts:2 -disablerule:BackupRule
so, deleting the two folders: (destinationFolder) and C:\Users\(user)\AppData\Local\Temp\PublishTemp\(tempFolder), and running the two commands above "by hands" in command prompt, I obtained the wanted result

How do I mimic the Publish button in Visual Studio from within the .csproj file?

I have a Visual Studio 2013 web application project and I have a Local File System publish profile setup for it. When I right click on the project in Visual Studio and choose "Publish" I can publish just fine and everything behaves as expected. However, I need this publish to occur automatically on build because other projects in the solution depend on this project being deployed locally. In my case, the deploy goes into a $(ProjectDir)/Deploy folder.
How can I make it so when I build this project using msbuild myproject.csproj or right click Build, the project will be deployed per the .pubxml file?
What ended up being the solution was adding this to the end of my .csproj file.
<Target Name="Deploy" AfterTargets="Build">
<MSBuild
Projects="$(ProjectPath)"
Targets="WebPublish"
Properties="PublishProfile=LocalDeploy"
/>
</Target>
LocalDeploy is the name of my .pubxml file found in $(ProjectDir)Properties/PublishProfiles.
For reference, here is the publish profile being used:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>True</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>$(MSBuildThisFileDirectory)\..\..\Deploy</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>

How to use Sqlite in WP8 project wihout referencing the Sqlite extension

I have a problem with Sqlite in my Windows Phone 8 app. I followed the ususal guides, where you have to add sqlite-net and sqlite-net-wp8 NuGet package, then add compilation parameter USE_WP8_NATIVE_SQLITE and then add link to Sqlite for Windows Phone Visual Studio Extension.
I have a problem with the last step because it requires specific Visual Studio extension to be installed and therefore it's not compatible with our requirement to have all source files and libraries in Git repository, without need to install any additional plugins when running Continuous integration or setting a machine for a new developer.
When I tried to add reference to the sqlite3.dll located in
C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\ExtensionSDKs\SQLite.WP80\3.8.7.4 \Redist\Retail\x86\sqlite3.dll
I got error "A reference to a higher version or incompatible assembly cannot be added to the project."
Is there a way how to overcome this problem and have all necessary Sqlite libraries in my Git repository, without referencing VS Extensions that need to be installed?
I know this is old, but I recently did something similar. Here is the approach I took:
Install the extension, and copy the files from C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\ExtensionSDKs\SQLite.WP80 and copy to your $(SolutionDir)packages directory
Edit the $(SolutionDir)packages\DesignTime\CommonConfiguration\neutral\SQLite.WP80.props file that is included in the package and change the path of IncludePath and LibraryPath:
<IncludePath>$(SolutionDir)packages\SQLite.WP80\latest\DesignTime\CommonConfiguration\Neutral;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)packages\SQLite.WP80\latest\DesignTime\$(PackageConfiguration)\$(PlatformTarget);$(LibraryPath)</LibraryPath>
Modify the SQLite.vcxproj file
A. Add Property groups to add location of sqlite3.dll
`
<PropertyGroup>
<SQLiteBase>$(SolutionDir)packages\SQLite.WP80\latest\Redist</SQLiteBase>
<SQLiteWin32Debug>$(SQLiteBase)\Debug\x86</SQLiteWin32Debug>
<SQLiteWin32Release>$(SQLiteBase)\Retail\x86</SQLiteWin32Release>
<SQLiteArmDebug>$(SQLiteBase)\Debug\ARM</SQLiteArmDebug>
<SQLiteArmRelease>$(SQLiteBase)\Retail\ARM</SQLiteArmRelease>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<SQLiteBinPath>$(SQLiteWin32Debug)</SQLiteBinPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<SQLiteBinPath>$(SQLiteWin32Release)</SQLiteBinPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
<SQLiteBinPath>$(SQLiteWin32Debug)</SQLiteBinPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
<SQLiteBinPath>$(SQLiteWin32Release)</SQLiteBinPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
<SQLiteBinPath>$(SQLiteArmDebug)</SQLiteBinPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
<SQLiteBinPath>$(SQLiteArmRelease)</SQLiteBinPath>
</PropertyGroup>
`
B. Change the ImportGroup for the props file to reference the path in solution:
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)packages\SQLite.WP80\version\DesignTime\CommonConfiguration\Neutral\SQLite.WP80.props" />
</ImportGroup>
C. Change the ItemGroup where the it references the SDK and change it to add the sqlite3.dll
<ItemGroup>
<CustomBuild Include="$(SQLiteBinPath)\sqlite3.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent>
</CustomBuild>
</ItemGroup>
This copying the SQLite SDK files "locally" with this extension https://visualstudiogallery.msdn.microsoft.com/1f027247-1e01-4ec6-8f5b-70dabb375217.

Resources