Build Action

什么是Build Action? Build Action is how the file relates to the build and deployment processes.

In the Windows Phone project of Visual Studio 2010, there are multiple build actions. What is the difference between them?

buildaction

* None : This file will not participate in compilation and will not be output. For example: the document file in the project, readme.txt.

* Compile : Participate in compilation and output. Mainly code files.

* Content : Does not participate in compilation, but will be output.

* Embedded Resource : This file is embedded in the DLL or exe generated by the main project. Mainly resource files.

* ApplicationDefinition : Similar to Page, but only used for the startup page of Silverlight (App.xaml by default).

* Page : All usercontrol/page/childwindow xaml in Silverligh belong to the "Page" build, and other build actions cannot connect the code behind file with the xaml file.

* CodeAnalysisDictionary : Custom CodeAnalysis dictionary. (Refer to http://blogs.msdn.com/b/codeanalysis/archive/2007/08/20/new-for-visual-studio-2008-custom-dictionaries.aspx )

* Resource:embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources

* SplashScreen : Welcome screen of Silverlight.

* DesignData: Sample data types will be created as faux types. Use this Build Action when the sample data types are not creatable or have read-only properties that you want to defined sample data values for.

* DesignDataWithDesignTimeCreatableTypes: Sample data types will be created using the types defined in the sample data file. Use this Build Action when the sample data types are creatable using their default empty constructor.

* EntityDeploy : Applies to the Entity framework.


WPF image and other path issues

                                                                                              Leo

In WPF, if you don’t pay attention, you will be confused by the path. Why is the image imported into the project not copied to the Bug directory? Why is the path not found when it is used? I searched the internet and haven't seen any good articles yet.

After a recent period of worries about the path problem, when I was learning WPF in the system today, "Application WPF In Context" accidentally found a very similar place, that is, set the type of each imported picture to Source, so I was inspired Was it because of this, I started to try!

 

I opened my project and found that the image path in it was not set to copy, and they were not copied. No wonder this is not automatically copied to the project bug directory.

 

When I looked down, I found out that there are many different options for Build action, so I checked, there are really many types, and then I found one option type is Embedded Resource, haha, I thought about a baby The pictures and templates in all of my projects have been re-set up.... The effect is good, because I know the problem, so I checked it on the Internet, specifically inquiring the usage of Build action: in the blog garden I found an article, extract the middle part:

 

None : This file will not participate in compilation and will not be output. For example: the document file in the project, readme.txt.

* Compile : Participate in compilation and output. Mainly code files.

* Content : Does not participate in compilation, but will be output.

* Embedded Resource : This file is embedded in the DLL or exe generated by the main project. Mainly resource files.

* ApplicationDefinition : Similar to Page, but only used for the startup page of Silverlight (App.xaml by default).

* Page : All usercontrol/page/childwindow xaml in Silverligh belong to the "Page" build, and other build actions cannot connect the code behind file with the xaml file.

* CodeAnalysisDictionary : Custom CodeAnalysis dictionary. (Refer to http://blogs.msdn.com/b/codeanalysis/archive/2007/08/20/new-for-visual-studio-2008-custom-dictionaries.aspx )

* Resource:embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources

* SplashScreen : Welcome screen of Silverlight.

* DesignData: Sample data types will be created as faux types. Use this Build Action when the sample data types are not creatable or have read-only properties that you want to defined sample data values for.

* DesignDataWithDesignTimeCreatableTypes: Sample data types will be created using the types defined in the sample data file. Use this Build Action when the sample data types are creatable using their default empty constructor.

* EntityDeploy : Applies to the Entity framework.

 

Original: http://www.cnblogs.com/Tealcwu/archive/2010/07/12/1775904.html

 

If you read this, you find that you have already figured it out. In fact, there is another place that should be paid attention to, that is, the path in the front and back when using it. My principle is to use the path generated by yourself the day before yesterday:

Method, just drag an Image on a page, and then set its properties, using the built-in VS

Obtain a path as shown below:

 WPF <wbr><wbr>Pictures and other path issues

Then set all the paths in Xaml to the paths just now and then change the name of the picture or the name of the resource.

"/Xxx.xxx.xxx;component/bin/Debug/Images/xxx.png". . . Ok, then we can use this path to set up these imagesources, which can prevent errors.

Be careful in the background, that is, you cannot use "/" at the beginning, such as new BitmapImage(new Uri("Resources/Images/xxx.jpg", UriKind.Relative)

So you can get it. If you add "/", the path under VS may be correct, but an abnormal error will occur after publishing and the path cannot be found.

For other similar resource files that do not need to be compiled, they can be set in this way.

Finally finished. . . .

Guess you like

Origin blog.csdn.net/lm393485/article/details/88892352