I'm developing an application targeting .NET Standard 1.4, using the new csproj style (not project.json), and trying to get a localizable resources file to become available throughout the project. I get compiler errors when including a resources file currently, stating that the resources member I'm trying to access is not defined.
(Note: my final solution will have to be consumed by a Xamarin Android project and a UWP project)
The csproj automatically includes the resources file as follows:
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
Did it miss a step in the generation? Why can't I access any of the members of my resources file throughout the assembly?
After pasting resource XML, make an edit to the .resx file to generate the C# class.
.resx files generate the corresponding C# file after editing the .resx. Since I was pasting XML and not making any edits in the .resx file, the class never got generated.
Related
I'm trying to get resource files to work in Xamarin.iOS from VS2012. Basically I've created a separate project (PCL), named xxxx.Localization, with two .resx files in it - Strings.resx and Strings.da-DK.resx. In both of them I have a string named String1 with localized version of 'Hello'. The project generates two dll's - xxxx.Localization.dll and da-DK\xxxx.Localization.resources.dll. The problem is that only the xxxx.Localization.dll is added to the final xxxx.app and then only the default language is available. How do I get da-DK\xxxx.Localization.resources.dll (and other languages) to be added to the app? Or is there any other way to do cross platform localization, that works?
I created a blackberry application but I am having problems publishing it on my web site. I have uploaded the jad, jar, alx and cod file (from which I extracted the whole content). I also added the missing MIME types. But when I try to download the application by requesting the jad file, I get a 500 error with the details saying that the file myproject-30.cod is missing.
So I looked at the list of cod file... sure enough, they go from 0 to 29. No 30, 31 or above. However, in the jad file, there are references for cod files for up to 110.
My question is: how can I configure eclipse to produce the jar file properly? Or, alternatively, how can I modify the jad file to delete references to the 30+ cod files? Or maybe it is that the cod file is missing files?
You may try with blackberry ant tools, task will look like this:
<target name="produce_ota">
<mkdir dir="${ota.dir}" />
<jadtool input="your_app_name.jad" destdir="${ota.dir}">
<fileset dir="${build.dir}" includes="*.cod" />
</jadtool>
</target>
This will produce all needed cod parts and jad file to ${ota.dir} assuming there will be built application in ${build.dir} directory.
Check out slashdev.ca tutorial - Blackberry development with Ant & Eclipse
For some reason, the JAD file was not recreated by the rapc compile tool. Basically, it was created a couple of week ago and that's it, so clearly it was not up-to-date. To force the eclipse plugin to recreate the file, I simply deleted it. The new file is now working fine.
I have several class libraries within my MVC application which each have a Settings file with its own configuration file. With each configuration file being App.config, how are these aggregated into one configuration file? Should the settings be placed in web.config? Suggested best practice?
When you build each class library you'll notice that the app.config file is copied to the bin\output folder with a name like "myclasslibrary.dll.config". This means that each DLL will have it's own config file each with a unique name. You can just include the *.dll.config files in your website's bin folder along with the DLLs and your settings will be picked up.
You can also combine settings from a library's app.config into the web.config file by adding new <section> declarations inside <configSections>.
This MSDN walkthrough has an example: http://msdn.microsoft.com/en-us/library/ms246220%28VS.80%29.aspx
Then you wont need separate config files.
I create my solution by using Asp.net MVC pattern which has at least 4 projects.
App.Models
App.Globalization
App.Controllers
References : App.Model and App.Globalization
App.Views
References : App.Model, App.Globalization and App.Controller
I need to create .net resources file for using by both App.Controller project and App.Views project. First, I try to create App.Globalization project for sharing resources. But I need to save resx file in App_Globalization folder in App.Views project and save designer.cs file(generated code of resx file) in App.Globalization project because it's easy to modify & save data in resources file.
Is it possible for creating separated resouce files for Asp.net MVC without using custom tool(s) or post-build command?
It's very easy by using the following step.
Add resource file to App_GlobalResources folder in App.Views project.
Set Build Action property of designer.cs file to None.
Unload App.Globalization project.
Edit App.Globalization project by adding the following code.
<Project>
<ItemGroup>
<Compile Include="..\App.Views\App_GlobalResources\WebApp.designer.cs">
<Link>WebApp.designer.cs</Link>
</Compile>
</ItemGroup>
</Project>
I have this team build target setup to after compile
<Target Name="AfterCompile">
<Copy SourceFiles="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12" DestinationFolder="c:\testing"></Copy>
</Target>
I want the folder structure copied from source to destination...
Amazingly I am getting this error
Could not copy the file "C:\TFS\NightlyBuild\Sources\Development_VS2008\MyCompanyName.SharePoint.12\"
to the destination file "c:\testing\", because the destination is a folder instead of a file.
To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.
As you can see I am indeed using the destinationfolder parameter, does anyone know what I am doing wrong?
I think it might be just because SourceFiles is a directory rather than the files you want to copy. Try this:
<Target Name="AfterCompile">
<ItemGroup>
<FilesToCopy Include="$(SolutionRoot)\Development_VS2008\MyCompanyName.SharePoint.12\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(FilesToCopy)" DestinationFolder="c:\testing\%(RecursiveDir)"/>
</Target>
This error happened to me not under Team Foundation project, but standalone one, and when I add new .dll file with build action ContentWithTargetPath. I wanted this library to be included in my output directory. Record for this action appears in one of the ItemGroup section in .csproj file like:
<ContentWithTargetPath Include="Resources\Libraries\libName.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ContentWithTargetPath>
But for some reason this is not enough to ContentWithTargetPath option works fine (I saw the explanation about it somewhere in StackOverflow, but don't remember where). You should manually add TargetPath subsection to ContentWithTargetPath like this:
<ContentWithTargetPath Include="Resources\Libraries\libName.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libName.dll</TargetPath>
</ContentWithTargetPath>
TargetPath subsection doesn't appear by IntelliSense while editing the .csproj file in Visual Studio, as well as it doesn't appear in libName.dll's properties window, so you should add this subsection by hand. This scenario comes out even in my Visual Studio Community 2017.
PS. You can edit .csproj file while in Visual Studio - unload this project and choose "Edit YourProjectName.csproj" option (right mouse click on unloaded project). Edit and save .csproj file, then reload the project.
You need something such as this:
<CreateItem Include="someFolder\**\*.*">
<Output ItemName="files" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="#(files)" DestinationFiles="#(files->'C:\folder\%(relativedir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
Or alternatively I've found the easiest way (if you want to be a bit more stringent about what to include/ exclude) is with some custom MSBuild tasks I've written: http://www.aaron-powell.com/blog.aspx?cat=AaronPowell.MSBuild.Tasks
You provide a source directory, a destination direction (support for network shares is provided) and file names/ extensions to exclude.
It's mainly because Team Build makes a real mess (particularly with web apps) when it run and it's not really possible to use the standard MSBuild copy tasks.
We are experiencing a lot of problems with postbuild xcopy commands. And we decided to avoid xcopy commands.
We are now including the files (which we want to copy) into project, and we are setting copy local property to "Copy if newer" and target directory (directory structure must be same in project)
It helps a lot.
Maybe it also fit your situation.
Copy task doesn't support copying directories apparently (as it's based on 'copy'), and xcopy will fails sometimes due to long filenames in source (>256 characters).
I did this (with robocopy):
<Exec WorkingDirectory="$(MSBuildProjectDirectory)"
Command='robocopy $(MSBuildProjectDirectory)\Main $(DropLocation) /S /COPY:DATS /NP /NFL /NDL /v' ContinueOnError="true" />
I had exactly the same message:
Error 103 Could not copy the file "obj\Release\xxxx.dll" to the destination file "bin\Release\xxxx.dll", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. xxxx
It happened (I don´t know why) that I had in the release folder another folder with the same name of the assembly (including extension), so Visual Studio could not create the assembly there. It is not a configuration in the project or solution, so I just deleted the folder (that I don´t know how it was created) and it worked.