I am using Visual Studio 2012. I have many projects each containing at least one .csproj file. The .csproj files contain this section:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IntermediateOutputPath>Assembly\Release\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<IntermediateOutputPath>Assembly\Debug\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<IntermediateOutputPath>Assembly\x86\Debug\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<IntermediateOutputPath>Assembly\x86\Release\</IntermediateOutputPath>
</PropertyGroup>
For some reason, whenever I open the project in Visual Studio, saving it changes the .csproj file to look like this:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IntermediateOutputPath>C:\Users\user\AppData\Local\Temp\vs9475.tmp\Release\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<IntermediateOutputPath>C:\Users\user\AppData\Local\Temp\vs9475.tmp\Debug\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<IntermediateOutputPath>C:\Users\user\AppData\Local\Temp\vs9475.tmp\x86\Debug\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<IntermediateOutputPath>C:\Users\user\AppData\Local\Temp\vs9475.tmp\x86\Release\</IntermediateOutputPath>
</PropertyGroup>
I have tried several things including adding a BaseIntermediateOutputPath element as well as creating separate conditional IntermediateOutputPath elements. The problem is that this messes with our version control and also generates errors when someone other than myself loads it (because of the local path). Can anyone tell me how to stop visual studio from changing the file every time we load it? This happens to everyone who opens it in Visual Studio 2012. It worked in 2010 but we are transitioning and need to fix this. It is a 2012 project.
Related
Last last week I started having an issue with every solution I've tried to build with Visual Studio. I was using VS 2019 and our organization had just pushed down some windows updates (not sure if that's related) but after the updates I was on VS 2019 version 16.8.4, .Net version 4.8.03752.
Whenever I try to build one of our solutions (I tried 3 different solutions after doing a free pull from the main branch of our repo) I get over 1000 errors which seem to be cascade errors from the OutputPath property not being set which seems to be related to several of the projects being arbitrarily changed from Debug to Release even though the solution is set to Debug | Any CPU.
Furthermore, if I examine the build tab on the project properties (or examine them in configuration manager) NO DEBUG CONFIGURATION IS SHOWN AS AVAILABLE. If I close Visual Studio it prompts to me save changes and if I do a comparison shows that it did indeed change the configuration of several projects form Debug to Release.
I have reproduced this on 2 separate machines, with fresh installs of Visual Studio 2019 (and 2017) and pulling fresh code from the repos. Other developers in my org an build the solutions just fine and their configurations show Debug | Any CPU across the board (i.e. I seem to be the only person in the world having this problem and I'm having it on every machine I've tried and with multiple versions of Visual Studio).
I also see errors saying that projects contains nuget references that are "missing" but if I restore nuget pacakges I get a messages saying they are all installed and there is nothing to restore. I also see the "missing" packages in the packages folder.
We use relative paths for the packages so it can't be the typical literal-path issue some people have. Besides which, my folder structure hasn't changed and we all use the same folder structure in our ord.
I am completely at a loss as to what to try next. My googlefoo has completely failed me in this regard.
I'm desperately hoping someone in the Stack Exchange world can offer a solution.
Thanks,
Greg.
Please check if your project's csproj file has missed these content:
You could directly add these at the bottom of the csproj file:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
After that, delete bin and obj folder.
Then, run update-package -reinstall under Tools-->Options-->Nuget Package Manager--> Package Manager Console to reinstall all nuget packages.
I have a Directory.Build.props file located in the same directory as the .sln file.
<Project>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DocumentationFile>bin\Debug\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DocumentationFile>bin\Release\$(MSBuildProjectName).xml</DocumentationFile>
</PropertyGroup>
</Project>
When I build the solution using MSBuild, I am able to generate the XML files properly. However, using a Build -> Rebuild Solution task in Visual Studio doesn't generate the XML file.
Is there a difference in how Visual Studio 2017 builds and uses Directory.Build.props as opposed to MSbuild?
I had added the directory.build.props as a solution item. This somehow prevented Visual Studio from picking it up and using it in the build process. Once I removed it as a solution item, this worked fine.
You also might have to delete your .vs directory (or portion of) as it seems to be cached there as well.
https://developercommunity.visualstudio.com/content/problem/248037/defaultbuildprops-with-langversion-is-not-used-by.html
You need to check that your project file contains next row in the beginning of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
Without row Import 'magic' doesn't happen. So, you need to insert this row to all your old projects
I'm tinkering with Xamarin.Forms on Visual Studio Community for Mac version 7.3.2
What I'm trying to accomplish is to convert all managed code to native executables using these options in MyApp.Droid.csproj:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
<AotAssemblies>true</AotAssemblies>
<EnableLLVM>true</EnableLLVM>
</PropertyGroup>
EmbedAssembliesIntoApk does embed the assemblies into the apk so I've set it to false, because those are precisely what I want to get rid of.
I've also set AotAssemblies and EnableLLVM to true so the managed code is AOT compiled and converted to native code.
Those options build a signed apk with the lib/ folder containing the files below and no assemblies folder, which is what I want.
lib/
armeabi-v7a/
libgdbserver.so
libmono-profiler-log.so
libmonodroid.so
libmonosgen-2.0.so
The problem is that if I clear the application data on the device and try to run the app again it won't start giving me some error saying 'no assemblies found' or 'conflicts between different versions of the same assembly'
Is it possible to build and ship a Xamarin.Forms application for Android without any managed assemblies, but only native executables?
Update:
I tried Xamarin Studio and it adds the option BundleAssemblies, so the project setting are as follows but Xamarin fails build the target:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AotAssemblies>true</AotAssemblies>
<EnableLLVM>true</EnableLLVM>
<BundleAssemblies>true</BundleAssemblies>
</PropertyGroup>
With those option on Visual Studio I get this executables:
lib/
armeabi-v7a/
libmonodroid_bundle_app.so
libmonodroid.so
libmonosgen-2.0.so
plus a bunch of files something.dll.so
Having the need to add a condition to the Post Build event in my Visual Studio 2013 project, I ended up with the following:
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>
I've added the condition Condition=" '$(OS)' == 'Windows_NT' " manually with a text editor to the CSPROJ file.
This works as expected, my solution builds successfully both in Visual Studio as well as in Travis CI.
What doesn't work:
When editing the Post Build event inside Visual Studio in the graphical editor, it seems to ignore the condition and simply stores the event twice:
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>
It doesn't matter whether I add the condition to the <PropertyGroup> node or the <PostBuildEvent> node.
In both cases the nodes are duplicated by Visual Studio upon saving.
My questions:
Any chance to somehow add the ability to ignore my Post Build event (which is the reason for the condition) on Travis?
Any chance to somehow tell Visual Studio to not duplicate the node with condition upon saving?
My projects appear to all have three <PropertyGroup> items.
One:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Two: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Three: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
FinalBuilder has been failing. When I go into the project file and add <OutputPath>bin\Debug\</OutputPath> to the first element in the .csproj file (an MSBuild file as I understand it), the build succeeds.
The remaining two elements already have <OutputPath> defined.
Is this a required field for all three elements? Why is it missing from the first element in my project files?
When MSBuild compiles a project, it takes OutputPath as an argument, to where it should place the build output.
The .csproj file has some default settings. It's in the first <PropertyGroup>.
In the conditional PropertyGroups, there are specific properties, to different configurations and platforms:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
Properties inside this node overwrites the default one, so it can specialize the build.
To hit the different PropertyGroups, MSBuild takes some argument, for example, hitting "Release|x86", the command looks like this:
msbuild /p:Configuration="Release" /p:Platform="x86"
MSBuild will use the properties from the default PropertyGroup, and overwrite/use properties from the PropertyGroups that meet the conditions, in this example "Release|x86" to compile the code.
Your problem sounds like MSBuild does not have the right arguments to evaluate the right PropertyGroups.